Re: [PD] Expr does not play well with ints?

2007-07-25 Thread Mathieu Bouchard

On Wed, 25 Jul 2007, Frank Barknecht wrote:

Mathieu Bouchard hat gesagt: // Mathieu Bouchard wrote:

Huh? [expr $1/$2] works here on Miller's 0.40.

I mean, it doesn't create all the time, see attached.


It won't expand $1/$2 to 0/0 or anything else that [expr] could make sense 
of, because it's a DOLLSYM. If you want 0.0/0.0 you need to use spaces 
because then each becomes a DOLLAR. That is something that I explain in a 
previous mail of this thread.


 _ _ __ ___ _  _ _ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-25 Thread Frank Barknecht
Hallo,
Mathieu Bouchard hat gesagt: // Mathieu Bouchard wrote:

> On Wed, 25 Jul 2007, Frank Barknecht wrote:
> >Frank Barknecht hat gesagt: // Frank Barknecht wrote:
> >>B. Bogart hat gesagt: // B. Bogart wrote:
> >>It does work, unless you're using an old, pre-0.40 version of Pd.
> >Ah, sorry, I should have tested it: [expr $1/$2] doesn't work. :(
> 
> Huh? [expr $1/$2] works here on Miller's 0.40.

I mean, it doesn't create all the time, see attached.

Ciao
-- 
 Frank Barknecht _ __footils.org_ __goto10.org__


expr-div-help.pd
Description: application/puredata


expr-div.pd
Description: application/puredata
___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-24 Thread Mathieu Bouchard

On Wed, 25 Jul 2007, Frank Barknecht wrote:

Frank Barknecht hat gesagt: // Frank Barknecht wrote:

B. Bogart hat gesagt: // B. Bogart wrote:
It does work, unless you're using an old, pre-0.40 version of Pd.

Ah, sorry, I should have tested it: [expr $1/$2] doesn't work. :(


Huh? [expr $1/$2] works here on Miller's 0.40.

 _ _ __ ___ _  _ _ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-24 Thread Frank Barknecht
Hallo,
Frank Barknecht hat gesagt: // Frank Barknecht wrote:

> Hallo,
> B. Bogart hat gesagt: // B. Bogart wrote:
> 
> > Ah, I see now.
> > 
> > I could not use that method, since 8/6 was an example, and I wanted to
> > do $8 / $6, so treating "$8" as a symbol would not have helped.
> 
> It does work, unless you're using an old, pre-0.40 version of Pd.

Ah, sorry, I should have tested it: [expr $1/$2] doesn't work. :(

Ciao
-- 
 Frank Barknecht _ __footils.org_ __goto10.org__

___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-24 Thread Mathieu Bouchard

On Tue, 24 Jul 2007, B. Bogart wrote:


Ah, I see now.
I could not use that method, since 8/6 was an example, and I wanted to
do $8 / $6, so treating "$8" as a symbol would not have helped.


Ah, caution with that: literals like 8 6 8.0 6.0 and pd's substitutors ($1 
$2 $3) work in the same way in this case, but [expr]'s own substitutors 
($f1 $f2 $f3) don't have that int-vs-float confusion problem because then 
[expr] does not attempt to read those floats as being text.


 _ _ __ ___ _  _ _ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-24 Thread Frank Barknecht
Hallo,
B. Bogart hat gesagt: // B. Bogart wrote:

> Ah, I see now.
> 
> I could not use that method, since 8/6 was an example, and I wanted to
> do $8 / $6, so treating "$8" as a symbol would not have helped.

It does work, unless you're using an old, pre-0.40 version of Pd.

Ciao
-- 
 Frank Barknecht _ __footils.org_ __goto10.org__

___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-24 Thread B. Bogart
Ah, I see now.

I could not use that method, since 8/6 was an example, and I wanted to
do $8 / $6, so treating "$8" as a symbol would not have helped.

.b.

Mathieu Bouchard wrote:
> On Mon, 23 Jul 2007, B. Bogart wrote:
>>> Mathieu, are you really able to put 8.0 in an expr argument? In my PD
>>> (.39 ubuntu package) the 8.0 gets turned into 8 and remains an int.
>> Ah! [expr float(8) / 6] does the trick, I'm damn happy there is float()
>> in there!!!
> 
> if you write any character next to the number that causes pd to read it
> as a symbol, then pd won't rewrite it before expr reads it.
> 
> [expr (8.0) / (6.0)] = 1.25
> [expr 8.0 / 6.0] = 1
> [expr 8.0 /6.0]  = 1.25
> [expr 8.0/ 6.0]  = 1.25
> [expr 8.0/6.0]   = 1.25
> 
>  _ _ __ ___ _  _ _ ...
> | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada



___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-23 Thread Mathieu Bouchard

On Mon, 23 Jul 2007, B. Bogart wrote:

Mathieu, are you really able to put 8.0 in an expr argument? In my PD
(.39 ubuntu package) the 8.0 gets turned into 8 and remains an int.

Ah! [expr float(8) / 6] does the trick, I'm damn happy there is float()
in there!!!


if you write any character next to the number that causes pd to read it 
as a symbol, then pd won't rewrite it before expr reads it.


[expr (8.0) / (6.0)] = 1.25
[expr 8.0 / 6.0] = 1
[expr 8.0 /6.0]  = 1.25
[expr 8.0/ 6.0]  = 1.25
[expr 8.0/6.0]   = 1.25

 _ _ __ ___ _  _ _ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-23 Thread B. Bogart
Ah! [expr float(8) / 6] does the trick, I'm damn happy there is float()
in there!!!

Thanks all,

B. Bogart

B. Bogart wrote:
> Mathieu, are you really able to put 8.0 in an expr argument? In my PD
> (.39 ubuntu package) the 8.0 gets turned into 8 and remains an int.
> 
> Hmm?
> 
> B. Bogart
> 
> Mathieu Bouchard wrote:
>> On Mon, 23 Jul 2007, B. Bogart wrote:
>>
>>> So I've been doing lots of calculations with expr and creation
>>> arguments, and it seems to send an int when it should send a float way
>>> too often:
>>> [expr 8 / 20]
>>> returns 0!!!
>>> Have I lost my mind? Is my machine going crazy? or is expr actually
>>> doing what I see here?
>> expr supports the int type because [expr] comes from jMax/FTS/Max/etc.
>> So if you put a number without a dot it's parsed as an int. Then the
>> main difference between ints and floats is that an int divided by an int
>> is rounded towards zero (many languages do it like that but some others
>> round it always downwards instead; some others instead force the result
>> to be a float or a rational)
>>
>> What you can do is either [expr 8 / 20.0] or [expr 8.0 / 20] or
>> obviously [expr 8.0 / 20.0]
>>
>> You only need to make one of the two as float because float has priority
>> on int, so when a float comes into contact with an int, the int is
>> converted, even though float can't represent everything that int can,
>> e.g. compare
>>
>>   [expr 123456789%10] finds last digit of 123456789
>>   [expr int(123456789.0)%10] fails because float isn't that precise
>>
>> do not put a space before % in that first example! if you do, pd will
>> parse it as a number, turn it to float, then give it to [expr], which
>> determines that float % int = syntax error.
>>
>> cool, eh?
>>
>>  _ _ __ ___ _  _ _ ...
>> | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
>>
>>
>> 
>>
>> ___
>> PD-list@iem.at mailing list
>> UNSUBSCRIBE and account-management -> 
>> http://lists.puredata.info/listinfo/pd-list
> 
> 
> 
> ___
> PD-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list
> 



___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-23 Thread B. Bogart
Mathieu, are you really able to put 8.0 in an expr argument? In my PD
(.39 ubuntu package) the 8.0 gets turned into 8 and remains an int.

Hmm?

B. Bogart

Mathieu Bouchard wrote:
> On Mon, 23 Jul 2007, B. Bogart wrote:
> 
>> So I've been doing lots of calculations with expr and creation
>> arguments, and it seems to send an int when it should send a float way
>> too often:
>> [expr 8 / 20]
>> returns 0!!!
>> Have I lost my mind? Is my machine going crazy? or is expr actually
>> doing what I see here?
> 
> expr supports the int type because [expr] comes from jMax/FTS/Max/etc.
> So if you put a number without a dot it's parsed as an int. Then the
> main difference between ints and floats is that an int divided by an int
> is rounded towards zero (many languages do it like that but some others
> round it always downwards instead; some others instead force the result
> to be a float or a rational)
> 
> What you can do is either [expr 8 / 20.0] or [expr 8.0 / 20] or
> obviously [expr 8.0 / 20.0]
> 
> You only need to make one of the two as float because float has priority
> on int, so when a float comes into contact with an int, the int is
> converted, even though float can't represent everything that int can,
> e.g. compare
> 
>   [expr 123456789%10] finds last digit of 123456789
>   [expr int(123456789.0)%10] fails because float isn't that precise
> 
> do not put a space before % in that first example! if you do, pd will
> parse it as a number, turn it to float, then give it to [expr], which
> determines that float % int = syntax error.
> 
> cool, eh?
> 
>  _ _ __ ___ _  _ _ ...
> | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
> 
> 
> 
> 
> ___
> PD-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list



___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] Expr does not play well with ints?

2007-07-23 Thread Mathieu Bouchard

On Mon, 23 Jul 2007, B. Bogart wrote:


So I've been doing lots of calculations with expr and creation
arguments, and it seems to send an int when it should send a float way
too often:
[expr 8 / 20]
returns 0!!!
Have I lost my mind? Is my machine going crazy? or is expr actually
doing what I see here?


expr supports the int type because [expr] comes from jMax/FTS/Max/etc. So 
if you put a number without a dot it's parsed as an int. Then the main 
difference between ints and floats is that an int divided by an int is 
rounded towards zero (many languages do it like that but some others round 
it always downwards instead; some others instead force the result to be a 
float or a rational)


What you can do is either [expr 8 / 20.0] or [expr 8.0 / 20] or obviously 
[expr 8.0 / 20.0]


You only need to make one of the two as float because float has priority 
on int, so when a float comes into contact with an int, the int is 
converted, even though float can't represent everything that int can, e.g. 
compare


  [expr 123456789%10] finds last digit of 123456789
  [expr int(123456789.0)%10] fails because float isn't that precise

do not put a space before % in that first example! if you do, pd will 
parse it as a number, turn it to float, then give it to [expr], which 
determines that float % int = syntax error.


cool, eh?

 _ _ __ ___ _  _ _ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list