Question

In my JSP I have an integer array where each integer has 19 digits. I am passing this array to a javascript function. Since javascript supports numbers in the range +/- 9007199254740992, the last three digits of all the integers in integer array is converted to zeroes.

For example in JSP - the integer array is [6918384653328004118 , 9016587993063058147] In javascript function, I receive this integer array as [6918384653328004000 , 9016587993063058000]

Please let me know how I can pass the complete 19 digit integer array to javascript function.

Thanks, Surabhi

Was it helpful?

Solution

If you do not intend to use these integers for calculation, can you just pass to your Javascript as Strings and treat them as Strings in your JS code?

Instead of generating an array of numbers ([6918384653328004118 , 9016587993063058147]), change your JSP so it wraps your numbers in quotes (["6918384653328004118" , "9016587993063058147"]). Javascript interprets that as an array of Strings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top