Hi list, Deviding a int by a int results in a int returned like here; ------ <<<(2 / 3)>>>; //or even like this; 2 / 3 => float a; <<<a>>>; ------ Is that realy the intended behaviour? In that last case I personally find what happens a bit silly. If this realy is the way it should be I think it would be nice to add a line about this to the manual because I only found out what was happening exactly after several rounds of testing. Perhaps this is typical behaviour for some languages but I wasn't used to it. Yours, Kas.
Graham;
Note that you can get a float like this: 2 / 3.0 => float a; <<< a >>>;
Yes, I figured that out so it's not so bad. It's not a huge issue even if both sides would be int type variables because some temporary float variable will take care of it. It's certainly not going to keep anyone from doing anything. I wrote about it because I didn't expect it, it was tricky to find because the division was a part of a larger calculation and there was no documentation. I would be fine with it if it's deemed correct but in that case I'd like to sugest a note about it in our documentation. Three minutes with the manual would be much nicer then half a hour of staring at the VM in disbelief. I almost thought I needed some sleep... Something like; "if both sides are integers devide will return a integer, rounding down. If you need floats make sure at least one side is a float, for example by using a decimal point or by using a temporary variable" would be fine with me. Perhaps it might be better to have a more general text about the type returned by the math operations with a note that that might result in unexpected situations with the devide? Currently I think only the modulo's example covers floats. Yours, Kas.
participants (2)
-
Graham Percival
-
Kassen