Hi,
  Does anyone know a function to count how many digits do u have after the decimal or before?  I am trying to use this information to build a number in my display window. 


Thanks Slim
Posted on 2005-07-13 22:55:50 by slim515
Is your data a string or a dword?
Posted on 2005-07-14 04:46:58 by roticv
Its a string which i convert to a Dword.  I know how to convert from one to another.  I would like a function that works with dword or a string it doesnt matter. 

thanks slim
Posted on 2005-07-14 16:49:17 by slim515
Simple solution for a string containing a decimal number
USAGE
teststr db '1234566.4403',0
push teststr
call GetDigitCount


GetDigitCount:
;IN ptr to STRING holding the number
;RETURN EAX = number of digits before decimal & EDX = number of digits after the decimal
PUSH esi
MOV esi, ; ptr to string
XOR eax,eax
XOR edx,edx
.LP1:
MOV cl, byte
INC esi
TEST cl,cl ; if it's null there's NO decimal
JZ .Ret
CMP cl, '.' ; check for decimal point
JE .Next
INC eax
JMP .LP1
.Next: ;count digits after decimal
MOV cl, byte
INC esi
TEST cl,cl ;check for null
JZ .Ret
INC edx
JMP .Next
.Ret
POP esi
RETN 4


If you want to get the number of digits before and after with a DWORD FP value I suggest you check out
http://www.psc.edu/general/software/packages/ieee/ieee.html
It will show you how the bits are formated in single and double precision values, although deriving the digit count from those bits seems to be a considerable pain in the butt.
Posted on 2005-07-14 19:17:10 by r22
thank you very much r22

slim

Posted on 2005-07-15 00:00:50 by slim515
It will be easier to work with string as all you need to do is do a scan through as what r22's code is doing.
Posted on 2005-07-15 07:25:32 by roticv
If it doesn't have to be superoptimized it's maybe easier to do:

invoke lstrlen, addr string
mov ecx, eax
mov eax, byte ptr '.'
repnz scasb
sub ecx, 1    ; needed?  double-check

The result should be in ecx.
Posted on 2005-07-18 01:21:32 by grv575