What’s wrong with this division? [duplicate]

It’s doing integer division in the first example as this is the default type for a numeric literal. Try changing it to -1.0/9 (or 1d/9d – the d suffix indicates a double) and you should get the same answer.

Leave a Comment