19 digit value getting rounded-off to the next digit from 17th digit onwards
19 digit value getting rounded-off to the next digit from 17th digit onwards
puneet705
Posts: 3Questions: 1Answers: 0
If I give the value as 8112115288888871719, the database and Java code has the same value but while rendering it to UI using Datatables it comes as 8112115288888872000. I tried with hardcoded value as well but even that is getting rounded off. Any idea why it is happening?
This discussion has been closed.
Answers
Seems to be okay here: http://live.datatables.net/jujufiwa/1/edit .
Perhaps you can link to a test case showing the issue.
Allan
Hi Allan, I have a column in the datatable where this value is getting retrieved from the database using Java code. The datatable code is written in a JSP file. I could see that in other screens as well, the same is happening
I'm afraid I can't offer any help without being able to see a test case, since as I showed with my link above, it should work.
Allan
Hi Allan,
I'm facing issues for the below test case
"aoColumnDefs": [
{
"sTitle": "ID",
"sType": "string",
"sClass": "center",
"mData": null,
"mRender": function(data, type,
full) {
alert("Hi");
return 8112115288888871719;
},
"aTargets": [0]
},
Output: 8112115288888872000
Thanks - you would need to use that number as a string: http://live.datatables.net/jujufiwa/3/edit .
The value you are using is simply too large to be stored precisely in the IEEE 754 numbers that Javascript uses. This is not a DataTables issue but rather a limitation of Javascript. For example, simply type
8112115288888871719
into your browser's console and press return. It is rounded with the IEEE 754 specification. That is not something DataTables is doing, but rather the browser's Javascript engine.Allan