Double.infinity should not exist

Problem

The problem I feel is that n / 0 does not throw an exception. Only n ~/ 0 throws an IntegerDivisionByZeroException. This is frankly completely unintuitive.

What even is the use of double.infinity anyway? I think that it should be removed as I assume that there is no real use case that requires double.infinity and could not be solved better.

Motivation

I just encountered a problem that was incredibly hard to detect because my app was stuck in a loop (which I know now) and I did not even consider the possibility of Infinity being used somewhere, which made any attempts of finding the issue harder.

Author: Fantashit

1 thought on “Double.infinity should not exist

  1. The Dart double type follows the IEEE-754 standard for floating point numbers, which requires positive and negative infinity, positive and negative zero, and not-a-number as values.

    There are no current plans to change this behavior, which is also shared by languages like Java, JavaScript and C#.
    The one place where Dart stands out compared to Java and C# is that division of two integers can create a double. In both Java and C#, the int / int operations is different from the int / double operation due to overloading. Dart does not have overloading, and it has a common supertype of int and double, which is why it has separate operations for integer and double division.

    Changing the behavior at this point is likely a breaking change.

Comments are closed.