File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Java fractions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java fractions" Watch "Java fractions" New topic
Author

Java fractions

Shirl Diva
Greenhorn

Joined: Sep 09, 2002
Posts: 21
Does anyone know how fractions are handled in java? How would you go about those kinds of computations?
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
Fractions are handled with doubles by default.

double quotient = 0;
double dividend = 2 ;
double divisor = 3 ;

quotient = dividend / divisor ;


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Shirl Diva
Greenhorn

Joined: Sep 09, 2002
Posts: 21
Thanx Marilyn. Is there a possiblity of a lose of precision - that occurs in division??
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Yes.
A few good links on this subject are mentioned in this past conversation in the Cattle Drive.
Making any sense?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java fractions