Page 1 of 1

How to add Float Big Endian

Posted: Fri Mar 03, 2017 2:10 pm
by wicked_laugh
So the old forum is gone. I missed out on this how to [Link]. Any one able to help a fella out? Thanks!

Re: How to add Float Big Endian

Posted: Fri Mar 03, 2017 8:29 pm
by panraven
Could you try these ?
Run this lua code 1st, In 1) Table/Lua Engine ; or 2) In a script subrround by {$lua} ... {$asm} tags

Code: Select all

function toBE(n,sz)
   if type(sz)=='string' then sz = sz:lower()end
   sz = sz or 4
   local ifmt = type(sz)=='number' and 'I'..sz or sz
   local ofmt = sz=='f' and "I4" or sz=='d' and "I8" or "I"..sz
   local p,u = string.pack,string.unpack
   return (u("<"..ofmt,p(">"..ifmt,n)))
end
This is a quick conversion of some type to 4bytes or 8 bytes Big Endian equivalent integer.

To search BE float, which is 4 bytes, select 4byte type (not float), and enter something like : toBE(1.5,'f')
'f' is for float, 'd' is for double which is 8bytes.

But this method only for exact value search (ie. you know the in game float value exactly, not just approx.),
since there is no ce rounding to include possible tolerance, even in-between will not work.

bye~


ADDED:
google cache of OP's link:
[Link]

There are custom type scripts for BE float and double.

Re: How to add Float Big Endian

Posted: Sat Mar 04, 2017 2:45 am
by wicked_laugh
Hmmm. I should have been more detailed in my request. Stupid me. I was actually looking to add Float Big Endian code to the Auto Assembler, but I will try this out when I get home to see if it works. Thanks!