Why does Canvas not round negative numbers ending in 5 correctly in formula questions?

Jump to solution
dsmith19
Community Member

Why does Canvas not round negative numbers ending in 5 correctly in formula questions? It will round -.5 to 0, or -.635 to -.63, it's very frustrating to have Canvas mark the answers as wrong because the student rounded correctly and Canvas did not. This is the only instance that I've seen Canvas round incorrectly.

348796_pastedImage_1.png

0 Likes
1 Solution
James
Community Champion

 @dsmith19  

What rounding rules are you using? There are many of them to choose from.

The one I hear most often, and that we teach our students in school around here (Central Illinois), is to look at the next digit and if it is a 4 or less, round down; if it is a 5 or higher, round up.

Following that rule, if I wanted to round -0.635 to 2 decimal places, then I would look at the 5 in the thousandths place and say I should round up. When I round up -0.635, I get -0.63. To get -0.64 would be rounding down.

The same thing with -0.5. 0 is bigger than -0.5 (round up), while -1 is less than -0.5 (round down).

The IEEE 754 standard for floating-point arithmetic defines five types of rounding. It was designed to address many differences between languages in rounding. They support ties going towards the even number (-0.5 goes to 0 but -0.635 goes to -0.64), rounding ties away from zero (negative numbers round down while positive numbers round up), and three types of directed roundings (truncation, ceiling, and floor). Strangely, it doesn't mention what we teach in our schools.

Some computer languages support rounding away from 0, which is what it seems you want. JavaScript, which is the language used in the browser which is where the formula questions are generated, uses the rule I am most familiar with.

Math.round() - JavaScript | MDN 

If the fractional portion of the argument is greater than 0.5, the argument is rounded to the integer with the next higher absolute value. If it is less than 0.5, the argument is rounded to the integer with the lower absolute value. If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞. Note that this differs from many languages' round() functions, which often round this case to the next integer away from zero, instead giving a different result in the case of negative numbers with a fractional part of exactly 0.5.

What I do with formula questions is never round and then specify a tolerance. If I have an exact answer of -0.635 and allow a tolerance of 0.005, then both -0.63 and -0.64 would be considered correct.

Another possibility with -0.635 is the inability to exactly represent a decimal number in binary. It may be -0.63500000001 or -0.63499999999 instead of -0.635. If it was -0.63499999999, then it would round to be -0.63. That doesn't explain the -0.5, which can be represented exactly. However, the JavaScript rules for rounding do explain the behavior.

View solution in original post

0 Likes