Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes decimal  part Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "decimal  part" Watch "decimal  part" New topic
Author

decimal part

James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

How to get only the decimal part of a number.??


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

sorry .. got it
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
Well done but please tell us what you did, so others can learn too.
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

(int) (Math.random()*100)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38016
    
  22
That gives us something different from what I had expected; that will give an almost random number in the appropriate range, 0 to 99 inclusive.
I thought you meant d % 1 where d is a double number. That will of course only work within the range of precision of a double.
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

edited
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: decimal part
 
Similar Threads
getting numberformatexception For input string: "500.0"
How do I remove decimal part of double?
ExamLab Question - Formatting
Decimals not converting to correct fractions
How to distinguish int , float , long and double?