# The MASM Forum

## Projects => Rarely Used Projects => GoAsm => Topic started by: shankle on May 01, 2015, 02:12:49 AM

Title: ftp problem
Post by: shankle on May 01, 2015, 02:12:49 AM
4-30-2015

hdc        dq  0
n1         dq  0
buf        db '              ',0
Value      db '           ',0   ; keyed in value

"%g",[n1]

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.
Title: Re: ftp problem
Post by: jj2007 on May 01, 2015, 02:45:40 AM

What is the last parameter?
Title: Re: ftp problem
Post by: dedndave on May 01, 2015, 03:05:25 AM
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
Title: Re: ftp problem
Post by: shankle on May 01, 2015, 03:12:52 AM
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?
Title: Re: ftp problem
Post by: jj2007 on May 01, 2015, 03:20:34 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.
Title: Re: ftp problem
Post by: qWord on May 01, 2015, 07:22:05 AM
I 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).
Title: Re: ftp problem
Post by: shankle on May 04, 2015, 08:25:40 PM
Thank you qWord,
The conversion specifier was causing most of my problems.
Still don't completely understand all that they can do.