Skip to content
Advertisement

Convert double to float in Java

I am facing an issue related to converting double to float. Actually, I store a float type, 23423424666767, in a database, but when we get data from the database in the below code, getInfoValueNumeric(), it’s of double type. The value we get is in the 2.3423424666767E13 form.

So how do we get a float format data like 23423424666767?

2.3423424666767E13 to 23423424666767

JavaScript

Advertisement

Answer

Just cast your double to a float.

JavaScript

Also notice that the primitive types can NOT store an infinite set of numbers:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement