| 01-11-2007, 03:55 PM | #1 |
JASS:local integer lvl = GetUnitAbilityLevel(u, 'A047') local real dur = 1.0 + R2I(lvl) I just noticed this in the code for one of my spells, and WC3 has been parsing it like it was no problem at all. |
| 01-11-2007, 04:05 PM | #2 |
well real can store integers =/ |
| 01-11-2007, 04:25 PM | #3 |
I think it's for the same reason this works:Set r = 0.234 * 3 3 is technicaly an integer, but real calculations can work with them. |
| 01-11-2007, 04:37 PM | #4 |
I think it turns them into reals. Hence why 3. is faster than real calculations with 3 (I want to put a fullstop there). |
| 01-11-2007, 04:43 PM | #5 |
I know what you mean, but it just seems weird that it would work like that. But if you do something like... JASS:function Bob takes integer i returns real return i endfunction It doesn't make sense to me why R2I(SomeReal) would be any different. Is it just for calculations that WE makes this distinction? Or are there other cases where it passes too? |
| 01-11-2007, 05:09 PM | #6 |
Well, I tested it in Jasscraft, and yes, it's weird. But, it gives you wrong values?? I suggest to post this issue to Pjass thread, so the program can give some warnings. |
| 01-11-2007, 05:09 PM | #7 |
As far as I know, real values are special (Vex, Pipe and other masters could explain you exactly why) because they are not simply "imported" from C++ float values. Therefore, plain conversions are not allowed. ~Daelin |
| 01-11-2007, 05:17 PM | #8 |
integer values are automatically converted to reals when used in operations, comparisons with reals or assigments to real. Therefore I2R is probably the least useful native. The only exception is when used as return values. I would dare to say that this is to allow the return bug conversion between integer and real. But that's probably a huge assumption. |
