// Path: src/main/java/javafixes/math/Decimal.java
// public static Decimal decimal(long unscaledValue, int scale) throws ArithmeticException {
//     while (unscaledValue != 0
//             && ((int) unscaledValue & 1) == 0
//             && unscaledValue % 10 == 0) {
//         unscaledValue /= 10;
// 
//         if (scale == Integer.MIN_VALUE) {
//             throw new ArithmeticException(format("Scale underflow - can't set scale to less than '%d'", Integer.MIN_VALUE));
//         }
//         scale--;
//     }
// 
//     return new LongDecimal(unscaledValue, scale);
// }
// 
// Path: src/test/java/javafixes/test/Random.java
// @SafeVarargs
// public static int randomInt(int from, int to, Function<Integer, Boolean>... validityConditions) {
//     return generateValidValue(
//             // typecast it to long as otherwise we could get int overflow
//             () -> (int) ((long) (Math.random() * ((long) to - (long) from + 1L)) + (long) from),
//             validityConditions
//     );
// }


import org.junit.Test;
import java.math.BigInteger;
import static javafixes.math.Decimal.decimal;
import static javafixes.test.Random.randomInt;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
package javafixes.math;




public class DecimalPrecisionTest {

    @Test
    public void shouldFindNumberOfLongDigits() {
        assertThat(decimal(0, randomInt()).precision(), equalTo(1));
        assertThat(decimal(1, randomInt()).precision(), equalTo(1));
        assertThat(decimal(-1, randomInt()).precision(), equalTo(1));

// Path: src/main/java/javafixes/math/Decimal.java
// public static Decimal decimal(long unscaledValue, int scale) throws ArithmeticException {
//     while (unscaledValue != 0
//             && ((int) unscaledValue & 1) == 0
//             && unscaledValue % 10 == 0) {
//         unscaledValue /= 10;
// 
//         if (scale == Integer.MIN_VALUE) {
//             throw new ArithmeticException(format("Scale underflow - can't set scale to less than '%d'", Integer.MIN_VALUE));
//         }
//         scale--;
//     }
// 
//     return new LongDecimal(unscaledValue, scale);
// }
// 
// Path: src/test/java/javafixes/test/Random.java
// @SafeVarargs
// public static int randomInt(int from, int to, Function<Integer, Boolean>... validityConditions) {
//     return generateValidValue(
//             // typecast it to long as otherwise we could get int overflow
//             () -> (int) ((long) (Math.random() * ((long) to - (long) from + 1L)) + (long) from),
//             validityConditions
//     );
// }


// Path: src/test/java/javafixes/math/DecimalPrecisionTest.java
import org.junit.Test;
import java.math.BigInteger;
import static javafixes.math.Decimal.decimal;
import static javafixes.test.Random.randomInt;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

package javafixes.math;




public class DecimalPrecisionTest {

    @Test
    public void shouldFindNumberOfLongDigits() {
        assertThat(decimal(0, randomInt()).precision(), equalTo(1));
        assertThat(decimal(1, randomInt()).precision(), equalTo(1));
        assertThat(decimal(-1, randomInt()).precision(), equalTo(1));

        assertThat(decimal(Long.MAX_VALUE, randomInt()).precision(), equalTo(19));