Hi
I have a program (.exe) which writes IDs to a file. These IDs are 10 digits number like 2216530427, 2216530426 - but somehow the program is buggy and instead I get - 2078436869, - 2078436870 which is exactly the length of the int (4294967296 ) minus the ID.
Now I`m searching for the most optimized way to fix these numbers. Instead of doing the arithmetic solution for every line which is the ID + 4294967296. I think bite shifting would be the most elegant way to fix this?
shift integer by its full length? Topic is solved
Re: shift integer by its full length?
So if I understood correctly, you want to replace 2078436869 with 2216530427 by doing 4294967296-2078436869 and apply the same action to the rest of other IDs?
Could you give an example on how the file looks like?
Could you give an example on how the file looks like?
Last edited by Smile_ on 21 Jun 2021, 03:57, edited 1 time in total.
Re: shift integer by its full length? Topic is solved
Code: Select all
MsgBox % (-2078436869 & 0xFFFFFFFF)
. "`n" (-2078436870 & 0xFFFFFFFF)
Code: Select all
ID := -2078436869
ID &= 0xFFFFFFFF
MsgBox % ID
Re: shift integer by its full length?
@SKAN Perfect!
Re: shift integer by its full length?
I'm extracting 32 bits from a 32 bit integer and in that process a signed number is getting converted to an unsigned integer.
I hope that makes sense.
An another approach.
I put a signed integer and get back an unsigned integer.
I hope that makes sense.
An another approach.
I put a signed integer and get back an unsigned integer.
Code: Select all
VarSetCapacity(I,4)
MsgBox % NumGet(NumPut(-2078436869,I,"Int")-4,"UInt")
Re: shift integer by its full length?
Now I understand
so the problem is that in my application the ID variable is signed int and it is out of range because the actual IDs are bigger than in example they start with 3x... so they out of signed int range that's why they get a negative sign -1x..
Now I wonder if its somehow possible to change the int declaration in my .exe application to unsigned int. That would be the best fix I think
so the problem is that in my application the ID variable is signed int and it is out of range because the actual IDs are bigger than in example they start with 3x... so they out of signed int range that's why they get a negative sign -1x..
Now I wonder if its somehow possible to change the int declaration in my .exe application to unsigned int. That would be the best fix I think
Who is online
Users browsing this forum: Google [Bot], Ronin_PL and 62 guests