Open boxxxie opened 12 years ago
enum contexts are giving me problems too.
var currencyContext = bigdecimal.MathContext.DECIMAL128;
undefined
bigdecimal.BigDecimal("123",currencyContext).toString()
java.lang.RuntimeException: Unknown call signature for obj = new java.math.BigDecimal: string function
Interesting. Which browser or Javascript engine are you using? Thanks!
Chrome. On ubuntu 11.10 I'll test on FireFox tomorrow. I found a work around and ill post it tomorrow.
I'm having the same issue, node on linux
> process.versions
{ node: '0.6.16',
v8: '3.8.9.16',
ares: '1.7.5',
uv: '0.6',
openssl: '1.0.1b' }
Has anyone solution / workaround been found ?
@chrismeyersfsu
Oddly, MathContext
only seems to accept strings:
var x = new BigDecimal('5');
var y = new BigDecimal('3');
var mc = new MathContext('precision=5 roundingMode=HALF_UP');
x.divide( y, mc ); // '1.6667'
// A precision of 16 digits and rounding mode HALF_EVEN.
// Notice that DECIMAL64 is a function.
x.divide( y, MathContext.DECIMAL64() ); // 1.666666666666667
// Two decimal places and rounding mode ROUND_HALF_UP.
x.divide( y, 2, 4 ); // '1.67'
// DOWN is a function, but ROUND_DOWN isn't.
x.divide( y, 6, RoundingMode.DOWN() ); // '1.666666'
x.divide( y, 6, BigDecimal.ROUND_DOWN ); // '1.666666'
it's from java.math, but i need to use it in the bigdecimal class.