Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/tp/Fraction.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public boolean isInteger() {
* @return true if the current fraction is strictly less than 0
*/
public boolean isNegative() {
return false;
double result = numerator/denominator;
return (denominator == 0 || result < 0)? true:false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heu, je ne comprends pas la logique... ???

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autre commentaire : double result = numerator/denominator risque toujours d'avoir des problèmes d'arrondi. Les opérandes de la divisions sont des entiers, donc le quotient sera un entier. Stocker ce résultat dans un double ne changera rien, on aura perdu de l'information. Tu dois "caster" les opérandes en double avant la division (une des deux suffit normalement).

}

/**
Expand Down