13 years
So, alot of people "know" that a real of 5.00 sometimes converted to integer would give a integer of 4.. (and the same for other "whole" reals aswell)
Now, I *could* buy the ordinary explanation (the reals sometimes are 4.9999 or 5.0001 instead of 5), except for one thing; I had a number that in ordinary cases was 1.00 (or 100%) that affected another number. However, when 0.05 (5%) was added and removed the affected number decreases as well as the integer-conversion of the modifier. I needed to doublecheck that the decrease was a 1-time thing only (thereby fixing it by increasing the 1.00 to 1.0001 or something). But my tests indicate that it was a lowering of the amount every time.. Here is a small report, if any1 has more information of the subject, please feel free to add.
Theory: A addition and subtraktion with the same real with digits of a real variable seems to actually lower the variable when it should have been returned to the same.
Test1: To quickly see if it works like that, I created a simple loop running through 300 times that adds and removes the same amount from a global real variable. A bjdebugmsg with the real*10000 (to see otherwise "hidden" digits) is called before and after the loop. Code:
To test if this is the way in non-loops, I tried the samething without loops, and it still decreases every time it is tested, but with lower speed (the loop generated about a minus of 3.5*10^-4 in the loop, the unlooped version had a to low number to get any good approx-number at all, but it seemed to be a little below 1.5*10^-5.
A testmap is attached. (:
Now, I *could* buy the ordinary explanation (the reals sometimes are 4.9999 or 5.0001 instead of 5), except for one thing; I had a number that in ordinary cases was 1.00 (or 100%) that affected another number. However, when 0.05 (5%) was added and removed the affected number decreases as well as the integer-conversion of the modifier. I needed to doublecheck that the decrease was a 1-time thing only (thereby fixing it by increasing the 1.00 to 1.0001 or something). But my tests indicate that it was a lowering of the amount every time.. Here is a small report, if any1 has more information of the subject, please feel free to add.
Theory: A addition and subtraktion with the same real with digits of a real variable seems to actually lower the variable when it should have been returned to the same.
Test1: To quickly see if it works like that, I created a simple loop running through 300 times that adds and removes the same amount from a global real variable. A bjdebugmsg with the real*10000 (to see otherwise "hidden" digits) is called before and after the loop. Code:
1 2 globals
3 real testnumber = 1.00
4 constant real TNA = 0.05
5 endglobals
6 7 function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
8 local integer i = 0
9 call BJDebugMsg("R2I: " + I2S(R2I(testnumber)) + " and R * 10000: " + R2S(testnumber*10000))10 loop
11 exitwhen i > 300
12 set testnumber = testnumber + TNA
13 set testnumber = testnumber - TNA
14 set i = i + 1
15 endloop
16 call BJDebugMsg("R2I: " + I2S(R2I(testnumber)) + " and R * 10000: " + R2S(testnumber*10000))17 endfunction
18 19 //===========================================================================
20 function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
21 set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
22 call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
23 call TriggerRegisterPlayerChatEvent(gg_trg_Untitled_Trigger_001, Player(0), "-test", true)
24 endfunction
25
To test if this is the way in non-loops, I tried the samething without loops, and it still decreases every time it is tested, but with lower speed (the loop generated about a minus of 3.5*10^-4 in the loop, the unlooped version had a to low number to get any good approx-number at all, but it seemed to be a little below 1.5*10^-5.
A testmap is attached. (: