nus-cs2113-AY2122S1 / pe-dev-response

0 stars 0 forks source link

Thrown out of program when adding stored ingredients #69

Open nus-se-bot opened 3 years ago

nus-se-bot commented 3 years ago

When trying to add beef to stored ingredients, I accidentally put the quantity into the argument. My command is "add ingr stored 40.000000000000001". Since 40.000000000000001 is not a stored ingredients, I should receive messages alarming me not to add non-stored ingredients. Instead I get this exception and was thrown out of the program.

image.png


[original: nus-cs2113-AY2122S1/pe-interim#70] [original labels: severity.High type.FunctionalityBug]

Dniv-ra commented 3 years ago

Team's Response

The reason for this bug was because we accepted the inputs as doubles and then ran a integer check on them before calling parseInt. Due to floating point arithmetic the "40.000000000000001" was parsed into 40 instead of 40.000000000000001 which went through our integer checks and threw an exception when calling parseInt. Thanks for pointing this out! This error only occurs on the fringe cases due to Double .parseDouble() being unable to accurately represent the number. As this case is quite rare the team believes this can be reduced to a medium.

image.png

Duplicate status (if any):

--