Numeric Type Limits


#1

I poked around a bit looking for some equivalent to TNumericLimits for Real but wasn’t able to find anything.

The use case is finding the shortest distance between a set of points and wanting to initialize the distance variable to the maximum value that Real supports.


#2

We hadn’t put in limits since we were considering making both Real and Integer 64-bit rather than 32-bit (which they are currently).

It is a good idea to have a proper mechanism for these values rather than using magic numbers though.

We’ll add the following constructors for Real and Integer:

// Real\!max().sk
() Real
  [
  3.402823466e38
  ]
// Real\!min().sk
() Real
  [
  1.175494351e-38
  ]
// Integer\!max().sk
() Integer
  [
  2147483647
  ]
// Integer\!min().sk
() Integer
  [
  -2147483648
  ]

So you would get the Real max value by using Real!max.

You can add these by hand for now and we’ll add them in a future update.

We’ll probably add some other handy values too such as pi. If there are any specific Real constants that you think would be useful, please let us know.


Note: These are created as constructors Real!max rather than class data members Real.@@max since the result values of a constructor cannot be changed whereas class data members could accidentally be changed. SkookumScript doesn’t have a way to tag data members as being constant. (Though we might add that capability in the future.)