On Sat, 28 Jan 2006, Hans-Christoph Steiner wrote:
I just had another idea for a handy thing when doing math: a method of getting the smallest and largest possible numbers. Basically, the Pd version of a #define INFINITY 1e37 (or whatever it is).
Wow, I didn't recall infinity being so small!
The largest possible finite values are FLT_MAX and FLT_MIN, which are +/- 2^128*(1-2^23).
Infinity values could be computed using [1 0( -> [/] and [-1 0( -> [/]. NaN (Not a Number) could be computed using [0 0( -> [/]. That is, if Pd were IEEE-compliant...
However you can still compute +infinity using [2 666( -> [pow].
[expr] is not IEEE-compliant either, but according to it, log(0) is -infinity and log(-1) is NaN, whereas according to Miller's [log], log(0) is -1000.
I think it would be handy to have as part of [float], like this: [float infinity] and [float -infinity]
But those would be mere shortcuts for what you can already do with two boxes.
(FLT_MAX and FLT_MIN) or maybe: [float max] and [float min] (FLT_MAX and FLT_MIN)
Please distinguish large finite values and infinite values.
[float max_exp] (FLT_MAX_EXP) [float min_exp] (FLT_MIN_EXP)
what is nice about those things is that they would increase portability between the current 32-bit float pd and a future 64-bit float pd.
However I don't like the fact that you can't use them everywhere.
If in [+ max_exp], max_exp is a float, then what does [symbol max_exp] do? How can those things work uniformly without having to add special code everywhere?
And perhaps [int] could also have the relevant versions of the same too.
It's not documented that [int]'s type is C's "int". Reading the helpfile, it could as well be implemented using C's truncf(). There is a difference: [2 666( -> [pow] -> [int] yields a negative number.
[int infinity] and [int -infinity] or maybe: [int max] and [int min]
machine integer types don't have infinities, but they do have extrema. The C type used by [int] is int, which goes from -2^31 to 2^31-1.
if [int] were using truncf(), [int]'s limits would be the same as [float]'s limits.
There's also a t_int type defined in m_pd.h but [int] doesn't use it.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada