### Author Topic: ftp problem  (Read 5143 times)

#### shankle

• Member
• Posts: 868
##### ftp problem
« 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

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

• Member
• Posts: 13274
• Assembly is fun ;-)
##### Re: ftp problem
« Reply #1 on: May 01, 2015, 02:45:40 AM »
invoke TextOut, [hdc],200,345,addr buf,10

What is the last parameter?
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

#### dedndave

• Member
• Posts: 8828
• Still using Abacus 2.0
##### Re: ftp problem
« Reply #2 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

#### shankle

• Member
• Posts: 868
##### Re: ftp problem
« Reply #3 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?

#### jj2007

• Member
• Posts: 13274
• Assembly is fun ;-)
##### Re: ftp problem
« Reply #4 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.
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

#### qWord

• Member
• Posts: 1475
• The base type of a type is the type itself
##### Re: ftp problem
« Reply #5 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).
MREAL macros - when you need floating point arithmetic while assembling!

#### shankle

• Member
• Posts: 868
##### Re: ftp problem
« Reply #6 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.