2
$\begingroup$

This question already has an answer here:

I was trying to comment on sequence https://oeis.org/A047229 in the OEIS, when one of the editors pointed out that the rounding is done wrong in this Mathematica one-liner:

Table[Round[(3*n - 3)/2], {n, 1, 57}]

In Mathematica I get the following results:

Round[1.5] = 2
Round[4.5] = 4
Round[7.5] = 8
Round[10.5] = 10

In school I was taught that you should round fractions equal to 0.5 up and that the correct answers are:

Round[1.5] = 2
Round[4.5] = 5
Round[7.5] = 8
Round[10.5] = 11

Is this a bug or a feature?

$\endgroup$

marked as duplicate by Simon Woods, ciao, Niki Estner, Community Sep 25 '16 at 7:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    $\begingroup$ It is stated clearly in the documentation of Round that this is a feature. $\endgroup$ – Coolwater Sep 25 '16 at 7:45
  • $\begingroup$ someone decided long time ago to do it that way in Mathematica. Too late to change. Different CAS systems can do it differently. In Maple round(4.5) gives 5 !Mathematica graphics, while Maxima does it like Mathematica. !Mathematica graphics $\endgroup$ – Nasser Sep 25 '16 at 7:56