Decimal numbers are showing in exponential form


Topic: Decimal numbers are showing in exponential form

Titanium asked 6 years ago

Expected behavior Display decimal numbers as they are, for example display this:

0.00000001

Actual behavior Values are being shown in exponential form, some are showing correctly but some are not, i.e. 1.5e-7

Resources (screenshots, code snippets etc.) I posted this error for Vue version as well but so far I see the issue has not been solved yet.


Mikołaj Smoleński staff commented 6 years ago

Hi there,

We're still working on that issue. In fact, it looks like it's a Vue props parser problem, rather than our component's bug. There is no way for You to change value into a string to avoid exponential form?

Best regards


Titanium commented 6 years ago

Hello

I just ran some tests and found that the issue in this case came from javascript itself, which is automatically converting decimals to exponential format. Although the format was already in string as the data is in JSON format, I used .toFixed(8) to force it to show up to 8 decimals.

It worked in Jquery but same method did not work in Vue.

Thanks


Titanium commented 6 years ago

Hello

I am posting again because I just found a solution for Vue problem as well, I used:

var x = 0.00000001; console.log(parseFloat(x).toFixed(8));

I guess opening this issue solved both of my problems :D

Thank you


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.6.0
  • Device: HP
  • Browser: Chrome
  • OS: Linux
  • Provided sample code: No
  • Provided link: Yes
Tags