About its usage, well some of my friends needed it for a bhop/surf timer and some other things related to an anti-cheat, I'm just sharing it there so nobody needs to write repetitive functions and make it into an extension in case people need it.
It could be bring up modulo since it doesn't exist in sourcepawn I think?
Quote:
Originally Posted by nosoop
This doesn't seem like an extension that needs game-specific builds; I'll send in a PR for that shortly.
May want to rework your tests as Double.FromFloat(1234.34567) loses precision and is rendered as 1234.345703125; would recommend the testing includes for that.
I've actually needed to work with doubles pretty much once in SourceMod (TF2's sentry think ticks uses that type in memory, for whatever reason, and I needed to override it). In that particular case I ended up going with extremely manual bit-twiddling for float / double conversion, but this would've been pretty nice to work with provided it could give me the value as a cell_t[2] (enum struct, perhaps?).
While I don't have a personal use for it, I could imagine it being handy for physics calculations or long-running operations. ¯\_(ツ)_/¯
|
Haha yeah you're right it doesn't need game specific builds, I was just too lazy to change it this way, but thanks for willing to put efforts into it.
As you said 1234.34570312 looses precision for some reasons I don't really know yet I think during casting to double, compiler optimization makes it loose precision, I need to investigate, but yeah bit manipulation should be way enough if sourcemod doesn't break the encoding of the float behind when it passes through cells. Float should be encoded with 0x449A4B10 (0x4093496200000000 for double) and not decoding after 1234.34567...
Though I heard FromString was working correctly.
And yeah I was thinking before making the extension about using two cells_t to encode the double, but I just said to myself that FromString is enough.
Anyway feel free to do any modifications you'd like I'll accept your PR once it's done (I didn't know about the testing include, it's nice)