[PD-dev] [float infinity] and [float -infinity]

Hans-Christoph Steiner hans at eds.org
Mon Jan 30 02:51:58 CET 2006


On Jan 29, 2006, at 3:57 AM, Mathieu Bouchard wrote:

> 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.

[1 0(---[/],  [-1 0(---[/],  [0 0(---[/], and [2 666(---[pow] don't  
work because they output "inf" and "-inf", and you can't do operations  
on them, like comparing them with [moses].  I think that supporting  
them in [float] makes sense since they are numbers more than objects.   
[float infinity] should output a float that can be used in comparisons.

And I do not think that all math objects should support these.  [float  
infinity] would output the float value of FLT_MAX, and then the math  
objects would use that value.

IEEE-compliance sounds good.  Feel like submitting some patches?

.hc


________________________________________________________________________ 
____

                     There is no way to peace, peace is the way.
						        				-A.J. Muste





More information about the Pd-dev mailing list