Unable to convert to the Javascript Number


Currently we have a formula to calculate distance between coordinates on client side but we are getting this error:

Unable to convert 0.67449695821270764679665 to the Javascript Number type because it will lead to precision loss. The maximum safe number of digits after the decimal point is 16.

Where should the precision be set?


hmm, this is weird.

doing it in the console i get no problem at all

when you define a Local Entity you can specify the precision of the Decimal attributes (and the limits are stricter actually, you cannot have more than 8 decimal digits).

I never got the error you're experiencing, but you may want to try using Round(0.67449695821270764679665, 16) on the assignment...

Hi Jorge,

Thank you for your reply - I've also come to using Round() function and managed to fix error by using round() function before sending parameters like this 

SyntaxEditor Code Snippet

Acos(Round(Sin(Round(PI()* testLatitude/180,15)) * Sin(Round(PI()*testLatitude2/180,15)) + Cos(Round(PI()*testLatitude/180,15)) *Cos(Round(PI()*testLatitude2/180,15)) * Cos(Round(PI()*testLongitude2/180 - PI()*testLongitude/180,15)),15))*6371

in this example trigonometric functions are client side wrappers for JS Math.* functions, I've also had to use Round() inside this functions when assigning JSNode output to function output.

I was wondering if it is something that should be done automatically behind the scenes without manual apply of round()?



I know it's an old thread, but I have the same problem, it occurs whenever you pass a decimal value to a JavaScript block that has more than 16 decimal places.

You always need to round the input value(s) to avoid runtime errors:

I agree with Mykola, it is something that should be done automatically behind the scenes (if actually needed) without manual apply of round(). 

In fact I don't see any reason why rounding is needed in this place, in other places it works even with more than 16 decimal places.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.