uhlryk / angular-dynamic-number

Highly customizable angular directive for numbers
64 stars 32 forks source link

Model Value going to scientific notation #48

Open kvieira90 opened 7 years ago

kvieira90 commented 7 years ago

When using this directive, losing decimal points and view value is getting distorted after 12 characters before the decimal (the num-int is set to 200). See screenshot

screen shot 2017-02-23 at 12 46 01 pm

screen shot 2017-02-23 at 12 48 37 pm
kvieira90 commented 7 years ago

Sorry if you've already answerd something like this but I couldn't find it in closed issues

uhlryk commented 7 years ago

Than you for your feedback. Very interesting case. I will check it if I can fix it somehow. In this module everything rely on normal js numbers.

kvieira90 commented 7 years ago

Spent some time digging into the problem and the issue lies in the fact that Javascript limits the size of integers to 64-bit floating point values. When you convert the input to Number, it causes the JS engine to automatically convert to scientific notation, thus throwing things off. I removed the conversion to Number, as well as any computation on that number so to get the full number represented in string form and work off that.