You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a representation of infinity would be really nice, as some algorithms (converted from floating-point math) sometimes turn a bit ugly, requiring hacks like boolean flags or additional checks.
E.g. for Fixed64 it could be:
public const long NaN = -9223372036854775808L;
public const long PositiveInfinity = 9223372036854775807L;
public const long NegativeInfinity = -9223372036854775807L;
public const long MinValue = -9223372036854775806L;
public const long MaxValue = 9223372036854775806L;
The main use for infinity is to guarantee there's never an overflow when dealing with unknown input, e.g. A + B <= PositiveInfinity; A + PositiveInfinity = PositiveInfinity.
Plus, infinity often serves as a perfect initial value for a FindMin algorithm. Of course you could use MaxValue instead, but sometimes you need to factor currentMin as input while searching, and the input needs to behave like infinity if nothing has been found yet.
Finally, together with NaN those constants should correctly cover most edge cases like Sqrt(<0), Log(0), Div(X, 0), Asin(>1), Tan(PiHalf), etc.
The text was updated successfully, but these errors were encountered:
I agree that infinities and NaNs would be a nice feature, but I'm not sure if there's a way to implement them without significant performance penalties to the operations. Performance is one of the biggest priorities of the library, so we decided to omit support for such special cases. It's not perfect, but I don't really see a way around this, so I'm closing the issue as wontfix.
For FindMin() and similar, you can indeed use MinValue/MaxValue.
Thank you for the awesome library!
Having a representation of infinity would be really nice, as some algorithms (converted from floating-point math) sometimes turn a bit ugly, requiring hacks like boolean flags or additional checks.
E.g. for Fixed64 it could be:
The main use for infinity is to guarantee there's never an overflow when dealing with unknown input, e.g. A + B <= PositiveInfinity; A + PositiveInfinity = PositiveInfinity.
Plus, infinity often serves as a perfect initial value for a FindMin algorithm. Of course you could use MaxValue instead, but sometimes you need to factor currentMin as input while searching, and the input needs to behave like infinity if nothing has been found yet.
Finally, together with NaN those constants should correctly cover most edge cases like Sqrt(<0), Log(0), Div(X, 0), Asin(>1), Tan(PiHalf), etc.
The text was updated successfully, but these errors were encountered: