In Java when we parse double value we will be able to parse values in the range 1.79E308 to -1.79E308. If we try to parse double value beyond this range we get infinity.
To parse any value beyond this range in Java we can use BigDecimal data type.
So to handle values beyond the above mentioned range use BigDecimal data type.
Well in most of the real life scenarios it's hypothetical to go beyond this range but QA (quality assurance)people will test your code for this.
In C++ we don't have BigDecimal data type, so it's a limitation of C++ to parse values beyond this range. Either you can throw exception or log an information about the support provided by your software or document the same.
Other way to handle this is to parse input value as String with some checks (decimal, grouping, no alphabets, only digits etc) and returning it as string. [This is possible when you don't have to do further calculation using this value in C++ but have java component on the other side to calculation]
Sunday, August 03, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment