split floating point number at decimal

jonathanb's icon

I'm trying to take a floating point number and divide it at the decimal into two separate integers. I've been looking at sprintf and regexp but have been unable to figure out how to achieve this. Can someone point me in the right direction, please?

jvkr's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This works to some extent. The issue generates some problems as in max it is impossible to pass a value like 012 when that would be part of e.g. 3.012. Leading zeros are automatically dumped. Wish it was that way in politics.

pdelges's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This may give you some ideas (not sure it works in all cases, but it seems so):

mzed's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I've done it like this:

Roman Thilenius's icon

something like [expr $f1 - int($f1)] will give you 0.012.

Grumbling Feathers's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Sorry to revive an old thread but I wanted to post a simplified solution to the problem.