File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java fractions

 
Shirl Diva
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how fractions are handled in java? How would you go about those kinds of computations?
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fractions are handled with doubles by default.

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

quotient = dividend / divisor ;
 
Shirl Diva
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Marilyn. Is there a possiblity of a lose of precision - that occurs in division??
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
A few good links on this subject are mentioned in this past conversation in the Cattle Drive.
Making any sense?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic