Michael Gillespie
01/27/2023, 9:32 PMgrandTotal=val(h.total)+val(h.tax)+val(h.shiptotal);
when serializing the total to send back in Ajax I get "847.8100000000001" but when I output it to page or cfdump the result I get 847.81, as expected..
edited to add, in ACF2016bdw429s
01/27/2023, 9:40 PMMichael Gillespie
01/27/2023, 9:45 PMbdw429s
01/27/2023, 9:46 PMbdw429s
01/27/2023, 9:47 PMScott Steinbeck
01/27/2023, 9:47 PMMichael Gillespie
01/27/2023, 9:48 PMMichael Gillespie
01/27/2023, 9:48 PMScott Steinbeck
01/27/2023, 9:49 PMMichael Gillespie
01/27/2023, 9:53 PMreplace(decimalformat(number,',','','all')
will solve it, I don't even want to think how many pennies I have lost (or gained) have happened before now.. reminds me of Richard Pryor's bank hackbdw429s
01/27/2023, 10:09 PMbdw429s
01/27/2023, 10:09 PMbdw429s
01/27/2023, 10:10 PMSince 77.1 has no exact representation, Excel stores it as
0100 0000 0101 0011 0100 0110 0110 0110
0110 0110 0110 0110 0110 0110 0110 0110
and then when you try to multiply it by 850, you get something very close to 65,535, but not exactly 65,535, because of the fact that 77.1 wasn't stored exactly because that would take infinite memory.bdw429s
01/27/2023, 10:11 PM.1 in decimal looks very simple, but has no direct way to represent it in base 2 without an infinitely repeating pattern. Sort of by the same tokek that the "simple" fraction of 1/3 can't be accurately represented in decimal because it's .3333 forever and ever.Michael Gillespie
01/27/2023, 10:14 PMbdw429s
01/27/2023, 10:15 PMbdw429s
01/27/2023, 10:15 PMMichael Gillespie
01/27/2023, 10:17 PMMichael Gillespie
01/27/2023, 10:19 PMbdw429s
01/27/2023, 10:19 PM.1 and the second one is .5
CFSCRIPT-REPL: createObject( 'java', 'java.lang.Long' ).toBinaryString( createObject( 'java', 'java.lang.Double' ).doubleToLongBits( .1 ) )
11111110111001100110011001100110011001100110011001100110011010
CFSCRIPT-REPL: createObject( 'java', 'java.lang.Long' ).toBinaryString( createObject( 'java', 'java.lang.Double' ).doubleToLongBits( .5 ) )
11111111100000000000000000000000000000000000000000000000000000bdw429s
01/27/2023, 10:20 PMMichael Gillespie
01/27/2023, 10:23 PMbdw429s
01/27/2023, 10:24 PMMichael Gillespie
01/27/2023, 10:25 PMScott Steinbeck
02/10/2023, 6:28 PMScott Steinbeck
02/10/2023, 6:28 PM