fmod function for lists?

Roald Baudoux's icon

I am looking for an object providing a modulo function with a float divider (also known as fmod) because vexpr's % deals only with integer division.

I'd prefer avoid js if another solution exists.

Emmanuel Jourdan's icon

You can calculate it with the following formula:a - b*int(a/b)

Max Patch
Copy patch and select New From Clipboard in Max.

Roald Baudoux's icon

Great!

Thanks.

Tj Shredder's icon

I prefer to do it like that, as the % is sort of not correct with negative values (in case you want to deal with dials turning around or octaves in a Midi context...)

Max Patch
Copy patch and select New From Clipboard in Max.

Tj Shredder's icon

When Emmanuel sent his vexpr based version of %, I adapted my old version which was based on iter and zl group. I suspected, that it would be more effective as vectors could be optimized. But it is actually slower. Is there any explanation for that? It seems strange for me...
(For now I stick to my old iterated version...)

Max Patch
Copy patch and select New From Clipboard in Max.