News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

ftp problem

Started by shankle, May 01, 2015, 02:12:49 AM

Previous topic - Next topic

shankle

        4-30-2015
      
hdc        dq  0
n1         dq  0
buf        db '              ',0
Value      db '           ',0   ; keyed in value


    invoke msvcrt:_atodbl, addr n1,addr Value ;convert string to double
    invoke msvcrt:sprintf_s, addr buf,sizeof buf,\
                   "%g",[n1]
    invoke TextOut, [hdc],200,345,addr buf,10

     bb = blanks on the screen
    If 0010000.00 is keyed in, this is what shows up in the textout
    instruction - 10000bbbbb
    If 0010000.55 is keyed in, this is what shows up in the textout
    instruction - 10000.5bbb
    If 0010000.44 is keyed in, this is what shows up in the textout
    instruction - 10000.4bbb

    I am trying to show a 2 decimal place value.
    Example: 0010000.88
    From what I can determine the instruction msvcrt:_atodbl
    is causing the problem. I have been on the Microsoft website and
   the info there did not help me at all.

jj2007

invoke TextOut, [hdc],200,345,addr buf,10

What is the last parameter?

dedndave

multiply the value by 100
round to nearest integer, as required (maybe use FISTP - it rounds for you)
convert it to a string
move the last 2 digits and the null terminator to the right
insert a decimal point

you will always get 2 places past the decimal, even if they are 0's

shankle

To:JJ2007  - I don't understand your Question

To: Dave  - I know about that, BUT this calculation is going into memory and used
                 all over the program.

There are other instances of using msvcrt:_atodbl that put out values that show the
the values correctly. They are in the 1000.55 range. Wonder if the size of the
value has anything to do with it?

jj2007

Quote from: shankle on May 01, 2015, 03:12:52 AM
To:JJ2007  - I don't understand your Question

Read the TextOut documentation. The last para is the len of the string, you are telling it the string is always 10 bytes long. No wonder you see garbage.

qWord

Quote from: shankle on May 01, 2015, 02:12:49 AMI am trying to show a 2 decimal place value.
    Example: 0010000.88
The conversion specifier "%010.2f" should do it. Remarks that values below 0.005 will be round to zero.
If you want a fixed format for all possible double-values (except NaNs), you might better use "%+.9E" (1+9 digits).
MREAL macros - when you need floating point arithmetic while assembling!

shankle

Thank you qWord,
The conversion specifier was causing most of my problems.
Still don't completely understand all that they can do.