Topic: Why are decimal numbers being round off ?

Titanium free asked 4 years ago

I am using mdbootstrap vue version in my project however when I insert rows in datatable and insert a decimal number from api like this:


It rounds off and just displays 0 in the table. When I hardcoded this value in a variable using javascript and displayed it, it showed me in exponential form like this for example:


How should I avoid this ? I just want to display the number as it is and not round off anything.

Mikołaj Smoleński staff answered 4 years ago

Hello Titanium,

Could You please share with us an example of data row here? I just tested our Datatable component for decimal numbers and it's working correct. 

One of my ideas is to change the number format into string before inserting into table.

Best regards

Titanium free commented 4 years ago

Well this is my code example:

var data = [{ "decimalNumber": 0.00010000 }];

for (var i = 0; i < Object.keys(data).length; i++) {{
DecimalNumber: data[i].decimalNumber, //this one displays 0
DecimalNumber2: 0.00000010, // this one shows in exponential form


Titanium free commented 4 years ago

Oh nevermind, I just noticed that its the server which is sending rounded values so this has nothing to do with mdbootstrap now.

Thanks for help

Mikołaj Smoleński staff commented 4 years ago

I'm glad to read that You found the problem. I am available on the support channel for further problems.

Best regards

Titanium free commented 4 years ago

@Mikolaj Smolenski

I just checked it seems like the table is converting into exponential form. However rounding off to 0 is not being done because it was server issue. 

But it is still converting into exponential form.

Mikołaj Smoleński staff commented 4 years ago

I am not sure if it's connected with our component. Please check again Your server configuration. Each time I pass decimal number to datatable it's not converting into expotential form.


Titanium free commented 4 years ago

Can you pass a number with atleast 8 decimals ? like this one 0.00000001

Mikołaj Smoleński staff commented 4 years ago

Ok, now I can see the problem. We'll add it to the list of bugs and try to fix in one of the next releases.

Best regards

Please insert min. 20 characters.


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



Specification of the issue

  • User: Free
  • Premium support: No
  • Technology: MDB Vue
  • MDB Version: 4.8.2
  • Device: HP
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No