Um, can somebody explain this to me why this is happening?
I tested on CSIDE and Dashingdon.
*temp a 3
*temp mod 1.1
*set a (a * mod)
Which results in: 3.3000000000000003
Changing a’s value results in:
4 * 1.1 = 4.4
5 * 1.1 = 5.5
6 * 1.1 = 6.6000000000000005
7 * 1.1 = 7.700000000000001
Here's my actual code which has different results:
I’ll only include the relevant bits.
*create smart_mod 1.0
After picking some choices:
*set smart_mod 1.1
*gosub_scene code stat "smart" 3 "I've always liked numbers since I was a toddler." 2
Here’s the gosub:
*params var amount msg type
*temp num amount
*if {var&"_mod"} > 1
*set num (amount * {var&"_mod"}) //(3 * 1.1)
*set {var} +num
Now the message part:
*temp numount (num-amount)
(+${amount} @{(amount != num) [+${numount}]|}
…which displays:
(+3 [+0.30000000000000027] Precocious) I've always liked numbers since I was a toddler.
I don’t know about this precocious toddler, but I’m pretty sure the result of (3.3 - 3) should just be 0.3.
It’s also weird since the above code said the result was 3.3000000000000003.
Changing the value of “amount”:
1 = 0.10000000000000009
2 = 0.20000000000000018
4 = 0.40000000000000036
5 = 0.5
6 = 0.6000000000000005
7 = 0.7000000000000011
There seems to be a pattern, but it doesn’t make sense.
I managed to solve it by adding:
*set numount -(numount modulo 0.001)
which makes it 0.3. But…
Where are those decimals coming from?