public static SObject makeNumber(int num) { // Bignums are sign + magnitude, so we need to convert // negative numbers to the positive equivalent. // We have to be tricky here because simply negating // the num might fall out of the range of representable // signed integers. Therefore, we cast it to a long first. return (SFixnum.inFixnumRange(num) ? SFixnum.makeFixnum(num) : (num < 0) ? (SObject)makeBignum((ulong)(-((long)(num))), false) : (SObject)makeBignum((ulong)num, true)); }
public static SObject makeNumber(long num) { // Bignums are sign + magnitude, so we need to convert // negative numbers to the positive equivalent. // We have to be tricky here because simply negating // the num might fall out of the range of representable // signed longs. We therefore add 1 before negating it // (effectively subtracting 1 from the magnitude) and // then add 1 after casting to restore magnitude. return (SFixnum.inFixnumRange(num) ? SFixnum.makeFixnum((int)num) : (num < 0) ? (SObject)makeBignum(((ulong)(-(num + 1))) + 1, false) : (SObject)makeBignum((ulong)num, true)); }
public static SFixnum makeFixnum(int num) { return(SFixnum.makeFixnum(num)); }
public static SFixnum makeFixnum(byte num) { return(SFixnum.makeFixnum(num)); }
public static SObject makeNumber(ulong num) { return(SFixnum.inFixnumRange(num) ? SFixnum.makeFixnum((int)num) : (SObject)makeBignum(num, true)); }