+ public static Decimal64 valueOf(final int scale, final short shortVal) {
+ final byte offset = offsetOf(scale);
+ final var conv = CONVERSION[offset];
+ if (shortVal < conv.minShort || shortVal > conv.maxShort) {
+ throw new IllegalArgumentException("Value " + shortVal + " is not in range ["
+ + conv.minShort + ".." + conv.maxShort + "] to fit scale " + scale);
+ }
+ return shortVal < 0 ? new Decimal64(offset, -shortVal, true) : new Decimal64(offset, shortVal, false);
+ }
+
+ public static Decimal64 valueOf(final int scale, final int intVal) {
+ final byte offset = offsetOf(scale);
+ final var conv = CONVERSION[offset];
+ if (intVal < conv.minInt || intVal > conv.maxInt) {
+ throw new IllegalArgumentException("Value " + intVal + " is not in range ["
+ + conv.minInt + ".." + conv.maxInt + "] to fit scale " + scale);
+ }
+ return intVal < 0 ? new Decimal64(offset, - (long)intVal, true) : new Decimal64(offset, intVal, false);
+ }
+
+ public static Decimal64 valueOf(final int scale, final long longVal) {
+ final byte offset = offsetOf(scale);
+ final var conv = CONVERSION[offset];
+ if (longVal < conv.minLong || longVal > conv.maxLong) {
+ throw new IllegalArgumentException("Value " + longVal + " is not in range ["
+ + conv.minLong + ".." + conv.maxLong + "] to fit scale " + scale);
+ }
+ return longVal < 0 ? new Decimal64(offset, -longVal, true) : new Decimal64(offset, longVal, false);
+ }
+ // <<< FIXME
+
+ // FIXME: this should take a RoundingMode and perform rounding
+ // FIXME: this should have a truncating counterpart
+ public static Decimal64 valueOf(final float floatVal, final RoundingMode rounding) {