hi

it seems that atodw doesn't convert string with negative numbers correctly, does it?

if i convert for example "-3" to a number, and convert that back to a string, i get "2543" or something..

what's wrong?

thx,
bye
Posted on 2002-05-30 12:23:46 by NOP-erator
Twos-complement numbers are dependant on data size:

BYTE -3 = 253 = 256 - 3
WORD -3 = 65535 = 65538 - 3
DWORD -3 = 4294967293 = 4294967296 - 3

See the pattern? atodw isn't designed for signed numbers, but Svin has a version on the board here and on Thomas' snippet library that supports signed numbers, iirc. Or, was it buliaNaza that posted the signed algo?
Posted on 2002-05-30 12:43:35 by bitRAKE
svins algo is von thomas' site, but it doesn't seem to be compatible with signed string numbers..
i also couldn't find any post of buliaNaza that helped me..
Posted on 2002-05-30 13:06:37 by NOP-erator
Posted on 2002-05-30 13:16:44 by bitRAKE
if worst comes to worst, just check for the '-' at the start of a number. If it isn't there, do as normal. If it is there just negate the result of the rest of the number.

--Chorus
Posted on 2002-05-30 16:16:02 by chorus

hi

it seems that atodw doesn't convert string with negative numbers correctly, does it?

if i convert for example "-3" to a number, and convert that back to a string, i get "2543" or something..

what's wrong?

thx,
bye


does convert correctly negative string to dword.
What you use to convert back?
Could you give a peice of code, you are making us guessing.

i get "2543" or something..

It's just piece of art this "or something" do you have problems with number recognision from your monitor.
Posted on 2002-05-30 18:33:18 by The Svin
Svin, I thought the same thing. It is hard to help those who don't want to help themselves. Does not appear he has put much effort into it - maybe it is not that important to him, then I say why should it be important to us?
Posted on 2002-05-30 19:30:22 by bitRAKE
hey,
of course it is important to me!
this is the piece of code:



invoke GetWindowText,iycompwnd,addr txtbuff,eax
invoke a2dw,addr txtbuff
invoke dwtoa,eax,addr txtbuff
invoke MessageBox,hWin,addr txtbuff,addr szDisplayName,0


if GetWindowText puts "-3" into txtbuff, this "-3" is converted to a normal number with a2dw. the result is in eax. if i convert it back to a string with dwtoa, i get "2533". I just said "..or something", because i wasn't at my computer at that time any more and couldn't check it..i just didn't remember..ok? sorry for that..

BUT: it seems that your algo (The Svin) that i found with the help of bitrake on thomas' site does the job!! i get "-3" after converting back to a string, so the whole thing is solved!

thanks to you guys..
(i also tried a code on sourcevault "parseradix" but the proc seemed to crash, dunno why...perhaps because it's 64 bit)

bye
Posted on 2002-05-31 04:14:05 by NOP-erator
invoke a2dw,addr txtbuff

So that is a2dw procedure, not atodw?
It's different procs and expect different input.
a2dw (by Iczelion) meant to be used with unsigned numbers, it doesn't expect "-" to be in string, so it
treats it as digit symbol and your get what you get.
it sub 30h("0") from "-"(2Dh)
2Dh-30h=-2 = 254
then it mul it by 10
254*10=2540
then it add 3 to it
2540+3=2543
:)
So this is whole arithmetic explonation where
2543 comes from.
Note - in your first post you said "atodw"!
And Actually you meant (and used) a2dw!
Be carefull next time when giving data about your problem. "2543" is not just any ("or something") garbage result, the number itself (as you now see) can hint you why it happens.
Posted on 2002-05-31 05:28:42 by The Svin
NOP-erator, I meant no offense by what I said. You can clearly see the difference between the first post and your last. I do understand that you were not in a possition to give precise information, but it really helps us help you. It is good to know the problem is solved.
Posted on 2002-05-31 06:24:11 by bitRAKE
ok, thanks to you guys!!

-NOP
Posted on 2002-05-31 06:37:14 by NOP-erator