Division of Float Numbers

Oğuzhan Tuğral's icon

Is that possible to divide an integer with a float number in Max/MSP

for example

1000 / 0.25 = 4000

Sébastien Gay's icon

It is possible. You have to initiate the [/] object with a float value (1. for instance). The output is then of course a float as well.

Wil's icon

Am I missing something?

You can also multiply 1000x4=4000

Roman Thilenius's icon

taking the question literally the anwer is "no".

because if you send the int "4000" to [/ 1.], the / object in float mode will convert the incoming integer operand to a float "4000."
:)

Oğuzhan Tuğral's icon

Thank you all, I solved the problem in another way and all these examples are great! I hope there would be an update in future versions we can more directly process such operations.

Best,

Source Audio's icon

what could be more direct then / 0.25
or expr $i1 / $f2, or all other options ?
more concern you should have about rounding
of division result if you need integer as output again.

1000 / 3.724 for example
should result be 268 or 269 ?


Roman Thilenius's icon

i´ve always wondered why expr $i1 / $f2 isn´t illegal, as that notation does not make sense.

Source Audio's icon

after so many years with max you should know ...

Roman Thilenius's icon

you did not read what i wrote.

only the second of two operands determines the operation mode, the first never.

so why write i? to confuse yourself? or because the same fancy mixed style is showed in the expr reference? :)

the output of [expr $i1 + $i2 + $i3 + $i4 + $i5 + $i6 + $f7 + $i8 + $i9] will be of data type float, but it is almost impossible to see that with this kind of notation.

Source Audio's icon

what you wrote is that "$i1 / $f1" makes no sense.
not that $i1 makes no sense.

One could say the same to t l or t s, both would accept same input
so why bother writing one over the oher ?
becuse s looks fancy ?

But I don't want to get into any discussiona about this,
simply have no time and interest ok ?


pdelges's icon

But if you send the message "10.9 3" instead of "10 3", then using $i1 or $f1 for the numerator will make a difference.

florian1947's icon

and this?
any float operand seems to determine mode of operation

Wil's icon

Ya'll are funny!
Better as a rule to multiply whenever possible.

Roman Thilenius's icon

sure patrick, but in the given case two ints should be sent, and then the operation should be done in float mode.

the latter requires you to type a float operand, so why now write i for the left operand? because we´re sending an int into it? we´re sending an int into the right one, too. :)

Wil's icon

”I refuse to let arithmetic decide questions like that“

or~

You are walking through a market in ancient Rome or Greece and come across a person selling flowers. They have only one flower left but you have a wife and 3 mistresses. So you ask the florist “ can you divide that last flower by .25?”> hoping to get 4 flowers.
The florist tells you that the OP post on Cycling74 forums in 2000 years in nonsense- better to multiply (you might lose the mistresses but not the wife)

Oğuzhan Tuğral's icon

If "mistress" is used in the way of what Guilio Cesare Monteverdi replied Giovanni Artusi on Prima Practica and Secondo Practica (a 16th century debate on music), things may be a little confusing about aforementioned arithmetic here.

"By First Practice he understands the one that turns on the perfection of the harmony, that is, the one that considers the harmony not commanded, but commanding, not the servant, but the mistress of the words, and this was founded by those men who composed in our notation music for more than one voice, was then followed and amplified by ... Josquin Desprez ... and others of those times, .."

I divide a float variable with a dynamic another float number that comes from a dynamic data. Float number from the data sometimes bigger than 1 and sometimes not. At points, it is not bigger than 0, because of the mechanism of the program, it requires you to change the operation and it makes things complicated though it is not insurmountable. But why do I have to spend more effort. It is much better I guess division and multipilication like simple operations might not be an obligation but a choose.

Wil's icon

@OĞUZHAN TUĞRAL

yes those stile antico composers were very dramatic! Thank you for the wonderful quote.

i think now your problem is more clear.
dividing 2 numbers is not the problem, it is when you sometimes get a zero. Then dividing by zero is a problem.

you can use an expression to stop the bad result-

in the case below, 0.01 and 0 give the same result

(you can also set min to the number box, but then you always have to use the number box)

Roman Thilenius's icon

diogenes once walked with a lantern over the marketplace in athens on a sunny afternoon. beeing asked what he would be doing there he replied he would be on a search for humans.

sometimes people are on their search for rational or irrational numbers and run into floating point. which pretends to be the same, but isn´t.


division by zero mostly appears during initialisation of max patches. in one half of these cases it can be fixed by writing [/ 1.] instead of [/ 0.], in other cases you need to fix your loadbang artwork.

or eventually close the console and ignore the error (not recommended if you want to reuse the patch in later projects.)

Oğuzhan Tuğral's icon

Thank you @WIL,

It is so helpful and I am so pleased to see that you pay attention to the problem, I appreciate. Certainly, I will use whenever it needs.

Sincerely,

Oğuzhan Tuğral's icon

Hi @Roman,

I have sometimes problems with basics, this was one of those cases. Thank you and all for your reply.

Best,