expr %($f1)

Jul 27, 2009 at 6:36am

expr %($f1)

i understand and accept that and why expr %($f1) cannot work
but please how else could i write it?

maybe its just too simple for me, but i dont find a working
expression on my own.

-110

 

#44904
Jul 27, 2009 at 9:04am

Hi Roman,

Is that what you trying to achieve ? :

[ expr $f1-int($f1/$f2)*$f2 ]

charles

#161676
Jul 27, 2009 at 7:26pm

Since fmod() is the standard C math function for floating-point modulo, one might expect [expr fmod($f1, $f2)] to work.

Of course, it doesn’t.

One could file a feature request for expr to support fmod() (or, better still, a % float-operator).

In the meantime, there’s Ch’s suggestion.

And, of course, the % object, which started supporting floats in an early Max 4 release.

#161677
Jul 27, 2009 at 7:48pm

thanks Ch, well hopefully you dont think i was just to lazy to
do it myself but yesterday i wasnt able to make it myself.

i have never made a float % abstraction myself (back in OS9
when % did not support floats) because i simply never needed
it to do floats, that is why i did not knew it offhand.

maybe i make one now.

but in this case i need stuff to work inside expr as this
saves patchcords and improves timing.

actually it is suprising that [expr] does not support “fmod”
or “%”, which is probably a less excotic function than natural
log (which noone ever uses) isnt it?

well, there will be a reason for it, we discussed the nature
of calling expr´s function earlier.

-110

#161678
Jul 28, 2009 at 7:01pm
Roman Thilenius wrote on Mon, 27 July 2009 21:48
which is probably a less excotic function than natural
log (which noone ever uses) isnt it?

Claiming “no one ever uses” any given function is just begging, pleading to be contradicted, isn’t it?

Frankly, I use natural log as often as any of the trig/log functions.

But more to the point is the rather idiosyncratic choices made by expr of which functions from the C math library to support and which to ignore. fmod() would definitely be useful.

Ideally, expr should support all the functions in ISO/IEC 9899:1999 that simply return a value. (ie, functions like frexp(double, int *) with a secondary return value as a pointer argument won’t fit into the expr paradigm).

Does Cycling 74 need an ‘official’ bug report to do anything about this?

#161679
Jul 31, 2009 at 1:12am

peter, ch,

i just found out that

[expr $f1 % $f2]

is how it actually works!

thats already the second new thing i learned about expr/if
this week. the whole thing seems to be more inconsistent than
in your most wet dream.

-110

#161680
Jul 31, 2009 at 6:49am

What do you mean Roman?

[expr $f1 % $f2] outputs the same result as [expr $i1 % $i2],
which is not what i expect.
the only difference is that if $f2 is between 0. and 1., then max crashes (the divide by 0 isn’t detected).

by the way, a nice thing about expr that is stated in the reference :
“Additional functions can be added by means of external code resources placed in Max’s startup folder.”
Have you ever tried that?

Charles

#161681
Jul 31, 2009 at 5:23pm
Ch wrote on Fri, 31 July 2009 08:49
What do you mean Roman?

you are right, it does not do float.

but the % sign alone was a surprise for me – i mainly asked
for a formula because i thought % would not work at all.

somehow i tend to think that everything which is fully
supported by the object is noted in the helpfile.

(like i said in the other thread the only additional “undocumented”
feature i knew about was comparison operators.)

Quote:
“Additional functions can be added by means of external code resources placed in Max’s startup folder.”
Have you ever tried that?

Charles

whoa. no!

Smile

and i assume i would need to write c classes for that …

but i dont have time to discuss that now, as i am going to
implement a coffeemachine in my startup folder asap.

-110

.

#161682

You must be logged in to reply to this topic.