fixed() returning wrong value for more than 16 character

 Hi,

 

I am getting issue with fixed() function. Its returning weird value for more then 16 character.

stripwith(fixed("1234567890123456",4,true),"~") ---"1234567890123456.0000"

 stripwith(fixed("123456789012345612",4,true),"~")--- "123456789012345616.0000"

 

Same way you add number at 17th position onwards you will come to know.

 

Kindly help me on this what could be the possible solution.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Your problem is Double precision floating point math. You can't possibly have more than 16 digits represented, and you're going to have massive gaps at the 16th decimal place between the numbers that can be literally represented with full precision. After nine and a half quadrillion you can't represent all integers any more, only even integers over 9.5 quadrillion.

    All programming languages have this problem with Double. There's simply NO way to get more than 16 digits precision, not in any programming language at all except C # with Decimal type or Java with the BigDecimal type, which amounts to Quadruple precision floating point, or other languages that might have larger than Double type numbers. With javascript it's still impossible unless you somehow code your own better datatype.

    You have to represent the number as a Text and leave it as Text. The number is too big for you to convert to any numeric type without losing precision. You have to send the Text to a plugin to do your math and then return the results from the plugin as Text, or wait for hackathon to be done because my hackathon project is actually the solution to this exact problem. I'll let you know how it goes.
  • How you will handle 100 Trillion number in audit reports with some 4 to 5 decimal points ?
    Requirement can be any but these limitation should not stop us for any conversion , some work around should be available. Why fixed() is not working with more numbers it should work.
  • How is your very large number stored? Does it come from the database?
Reply Children