Forums > MaxMSP

[expr] ??


Ste
February 14, 2013 | 10:17 am

hello
I am trying to cut out some digits from decimal number with simple expresion. For example if I have 4.33333 and I want to cut out last 3 digits with [expr $f1 - $f1 % 0.01], when I tried this max crashes. After that I tried with JS object

inlets = 1;
outlets = 1;

function msg_float( incoming ){
x = incoming;
y = x – x % 0.01;
outlet(0, y);
}

and it works fine. I know that there is a lot of ways to make this, but can anyone tell me why max crashes in this situation.

thanks


February 14, 2013 | 1:04 pm

… actually it shouldn’t… ;)

– Pasted Max Patch, click to expand. –

February 14, 2013 | 5:09 pm

FWIW neither expr nor js crash on my machine. bach doesn’t crash either ;-)



ak
February 14, 2013 | 9:27 pm

@emmanuel: lucky you. Here both 6.0.8 and beta-6.1.0 (osx.7.5) crash every time.



Ste
February 14, 2013 | 10:02 pm

I am quite new i programing, but I think that it is standart procedure. I tried with python and lua and it works. I have searched for it and found a topic i book about lua.

I am with max 6.0.8, OSX 10.7.5.

[attachment=214854,5029] [attachment=214854,5030]

Attachments:
  1. ScreenShot20130214at11.41.08PM.png

February 14, 2013 | 11:08 pm

Please send an example and more information like max version, crash log… to support.


February 14, 2013 | 11:47 pm

independent from the question wether modulo float works in the expression object or not … if you use expr anyway, you could just calculate the modulo yourself instead of using the % symbol.

that is not an answer to the question, i know, but a solution.

as far as i know % is not officially supported anyway and can be considered a second order undocumented feature, so if you want to be 100% safe you should make your own formula. :)

ust to give a hint, in prior versions of maxmsp the [%] object also was doing the integral job only.

-110


February 15, 2013 | 8:02 am

Same here, Max 6.0.8, OSX 10.6.8

Exception Type: EXC_ARITHMETIC (SIGFPE)
Exception Codes: EXC_I386_DIV (divide by zero)
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.cycling74.Max 0x0003debf ex_eval + 2594
1 com.cycling74.Max 0x0004061e expr_bang + 32
2 com.cycling74.Max 0x0006bb21 outlet_float + 851
3 com.cycling74.MaxAPI 0×02902687 outlet_float + 55
4 com.cycling74.number 0x1c0e9802 jflonum_mousedragdelta + 351

- btw, bach.expr’s % operator is the integer remainder as in expr, so $i1 % 0 returns 0 (it’s wrong, but better than crashing Max…), as $i1 % 0.01

aa



Ste
February 15, 2013 | 9:32 am

looks like the same.

Attachments:
  1. crash.txt

February 15, 2013 | 2:11 pm

Ok cool, I was just testing with 0.… not 0.01. I can reproduce now. We’ll have a look at it, but FWIW floating point modulo isn’t supported in expr anyway.


February 15, 2013 | 7:15 pm

Aside from the fact that trying to round to decimal digits when your computer is calculating in binary–a problem that has been discussed on multiple threads (for instance, this one–you would probably be better off using fmod() rather than % for floating-point modulo.

I’d need to check if [expr] support fmod. I think it does but I haven’t looked for a while. Otherwise, the calculation out of [expr] and use the [%] object, which started supporting floating-point mod quite a while back.



Ste
February 17, 2013 | 8:34 am

Thanks a lot for all replays!


Viewing 12 posts - 1 through 12 (of 12 total)