@@ -0,0 +1,2929 @@
+package scratchlib.util;%0A%0Aimport java.math.BigInteger;%0A%0Aimport scratchlib.objects.inline.ScratchObjectAbstractNumber;%0Aimport scratchlib.objects.inline.ScratchObjectFloat;%0Aimport scratchlib.objects.inline.ScratchObjectLargeNegativeInteger;%0Aimport scratchlib.objects.inline.ScratchObjectLargePositiveInteger;%0Aimport scratchlib.objects.inline.ScratchObjectSmallInteger;%0Aimport scratchlib.objects.inline.ScratchObjectSmallInteger16;%0A%0A%0A/**%0A * Utility class for converting Java number types into Scratch number types. The%0A * types used are always the smallest possible.%0A */%0Apublic class ScratchNumbers%0A%7B%0A    private ScratchNumbers()%0A    %7B%0A    %7D%0A%0A    /**%0A     * Converts the given number into a Scratch number type. The result may or%0A     * may not be a floating-point number type, depending on whether the input%0A     * is close to a mathematical integer.%0A     * %0A     * @param value The number.%0A     * @return The number converted to a Scratch number type.%0A     */%0A    public static ScratchObjectAbstractNumber of(double value)%0A    %7B%0A        if (value == Math.rint(value)) %7B%0A            return of((long) value);%0A        %7D%0A%0A        return new ScratchObjectFloat(value);%0A    %7D%0A%0A    /**%0A     * Converts the given number into a Scratch number type. The class is chosen%0A     * to be the smallest still able to contain the input.%0A     * %0A     * @param value The number.%0A     * @return The number converted to a Scratch number type.%0A     */%0A    public static ScratchObjectAbstractNumber of(long value)%0A    %7B%0A        if (value %3C 0) %7B%0A            if (value %3C Integer.MIN_VALUE) %7B%0A                return new ScratchObjectLargeNegativeInteger(%0A                        BigInteger.valueOf(value));%0A            %7D else if (value %3C Short.MIN_VALUE) %7B%0A                return new ScratchObjectSmallInteger((int) value);%0A            %7D else %7B%0A                return new ScratchObjectSmallInteger16((short) value);%0A            %7D%0A        %7D else %7B%0A            if (value %3E Integer.MAX_VALUE) %7B%0A                return new ScratchObjectLargePositiveInteger(%0A                        BigInteger.valueOf(value));%0A            %7D else if (value %3E Short.MAX_VALUE) %7B%0A                return new ScratchObjectSmallInteger((int) value);%0A            %7D else %7B%0A                return new ScratchObjectSmallInteger16((short) value);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Converts the given %7B@code BigInteger%7D into a Scratch number type. This is%0A     * either %7B@link ScratchObjectLargeNegativeInteger%7D or%0A     * %7B@link ScratchObjectLargePositiveInteger%7D, depending on the input's sign.%0A     * %0A     * @param value The number.%0A     * @return The number converted to a Scratch number type.%0A     */%0A    public static ScratchObjectAbstractNumber of(BigInteger value)%0A    %7B%0A        if (value.signum() %3C 0) %7B%0A            return new ScratchObjectLargeNegativeInteger(value);%0A        %7D else %7B%0A            return new ScratchObjectLargePositiveInteger(value);%0A        %7D%0A    %7D%0A%7D%0A

Add ScratchNumbers utility class