Skip to content

public boolean isNegative() change#25

Open
StreignardM wants to merge 2 commits into
EphecLLN:testfrom
StreignardM:patch-1
Open

public boolean isNegative() change#25
StreignardM wants to merge 2 commits into
EphecLLN:testfrom
StreignardM:patch-1

Conversation

@StreignardM

Copy link
Copy Markdown

return (numerator/denominateur)<0;

Comment thread src/main/java/tp/Fraction.java Outdated
@vvandenschrieck vvandenschrieck changed the base branch from master to test October 25, 2019 10:47

@StreignardM StreignardM left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

double result = numerator/denominator;
return (denominateur != 0 || result < 0)? true : false;

public boolean isNegative() {
return (numerator/denominateur)<0;
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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants