Skip to content
Advertisement

Tag: double

Generating a random double in an exclusive range

I’m trying to generate a random floating point number between but not including it’s lower and upper bounds (lower, upper). I’ve seen a lot of questions about generating a number from, and including it’s lower bound up to, but not including it’s upper bound [lower, upper), but that’s not what I’m after. I’ve come up with two “solutions” to the

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

How do I print a double value without scientific notation using Java?

I want to print a double value in Java without exponential form. It shows this E notation: 1.2345678E7. I want it to print it like this: 12345678 What is the best way to prevent this? Answer You could use printf() with %f: This will print dexp: 12345678.000000. If you don’t want the fractional part, use 0 in %.0f means 0

Advertisement