File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Extracting values from a double Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Extracting values from a double " Watch "Extracting values from a double " New topic

Extracting values from a double

Sri Ram

Joined: Feb 13, 2006
Posts: 20
I have a double number d = 15.33 .I want to do the below calculation.(ie) i want to seperate the whole number and the decimal part without using a splitter based on (.) to get the values.How can I do that??

e.g. 15.33 convert to 1520

Take decimal portion * 60 rounded. (0.33*60=20)

is what i want to perform? Please help.

Sriram<br />SCJP<br />SCWCD
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Why do not you want a splitter based on (.) ?

Rahul Bhattacharjee
LinkedIn - Blog
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Converting to text and splitting on the decimal point is both inefficient and subject to localisation issues (e.g. '.' versus ','). Using the Math library is the way to go, I think.

Look at Math.floor().

Compare and contrast to Math.ceil() and Math.round(), which have similar functionality, but subtle important differences.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: Extracting values from a double
It's not a secret anymore!