Author Topic: torque math/global vars not making sense  (Read 1324 times)

[img ]https://puu.sh/uv55g/fc564b6ab3.png[/img]
[img ]https://puu.sh/uv5kv/a22104c8fc.png[/img]
[img ]https://puu.sh/uv5mF/25e541a802.png[/img]

????

[img ]https://puu.sh/uv592/e4d10fe18d.png[/img]
[img ]https://puu.sh/uv5sj/647bfec1e4.png[/img]

???????????

[img ]https://puu.sh/uv5K1/0a3f570546.png[/img]

??????????????????????????????????
??????????????????????????????????
??????????????????????????????????
??????????????????????????????????


further investigation on fresh install:
[img ]https://puu.sh/uv5YL/f618eeb1bf.png[/img]
[img ]https://puu.sh/uv62a/b3ee9f72d4.png[/img]
appears to be an issue with floats??


edit: yes. apparently i just never encountered this before which is odd given how ive been coding for the past few years.





??????

anyone have any ideas why this engine has such broken global vars apparently?
« Last Edit: March 05, 2017, 07:45:43 AM by Conan »

That's not broken, just don't ever use == when doing floating point math, it won't work most of the time. (google why)

Don't see a logical explanation for the modulo right now but it works fine for positive numbers (what do you need the negative ones for?)

That's not broken, just don't ever use == when doing floating point math, it won't work most of the time. (google why)

Don't see a logical explanation for the modulo right now but it works fine for positive numbers (what do you need the negative ones for?)
hm okay. i just find it baffling ive never encountered this before, and that it is problematic with small numbers of decimal places.

as for negative modulos, i encountered it when i tried to modulo negative numbers to underflow when cycling between a set of index values. sure its not necessarily expected for people to be using it that way, but given that modulo math isn't particularly esoteric it should work.
« Last Edit: March 05, 2017, 07:47:09 AM by Conan »

Ok, I found what's happening with the modulo:



It's converting everything to unsigned integers first, so your -1 is now 2^32 - 1.

that's hilarious
will note that for the future, as I like using mod

hm okay. i just find it baffling ive never encountered this before, and that it is problematic with small numbers of decimal places.
there's no such thing as a float with a small number of decimal places
https://docs.python.org/3/tutorial/floatingpoint.html

This looks like a modulo vs remainder semantics issue

Torquescript returns a positive number for modulo which is nice.


I thought it was but it isn't. This is a bug in Torquescript.

So they should have set the msb/sign bit off (if it was set) before using C's modulo? Will this be fixed by the developers?
« Last Edit: March 07, 2017, 07:15:56 PM by Meldaril »

Will this be fixed by the developers?

This engine is from 2004. Blockland hasn't had a substantial update in many years. No.