Displaying floating point numbers in MASM32 visual projects

Started by etow, March 13, 2008, 11:00:23 PM

Previous topic - Next topic

etow

Hi

How do you output a real or floating point number from a Visual project in MASM32?

I know you use FpuFLtoA to display it but I am having trouble to make it display correctly in the static label in my Visual project in MASM32.

I need help please.

Thanks

etow

Hi

I need a routine (or procedure) that converts a real or floating point number in the corresponding text string for output in a string buffer.

Thanks


Adamanteus

 I  have, it's author algorithm supporting exponential output and varios presicion, but it's not free, countacts in profile.

etow

Hi

Here is my visual program which I have problems with displaying floating point numbers.
The program is in the zip file below.



[attachment deleted by admin]

hutch--

Egan,

I downloaded your source file but could not find an asm file in it.

Is this what you are looking for ?


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    .data
      item1 REAL10 1000.0000        ; 80 bit FP numbers

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main
    inkey
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    LOCAL fpo   :DWORD

    mov fpo, real10$(FP10(1234.5678))   ; literal using a macro
    print fpo,13,10

    mov fpo, real10$(item1)             ; address of item in .DATA section
    print fpo,13,10

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start


This is the output.


1234.567800
1000.000000
Press any key to continue ...


LATER:

RE: Writing string to a static control.

1. Get the handle of the static control, even if you have to use GetDlgItem() and then use SendMessage() with WM_SETTEXT or alternatively use the API SetWindowText() and you can display the string that contains the result in the static control.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

hutch--

Here is a short example of how to convert string to FP and back again then display it in an edit control. The conversion method is a bit crude as I hacked one of Greg's macros but the general idea of how to display results of FP should be easy enough to follow.

If you are familiar with ray Filiatreault's fpu library his conversions in both directions should be useful.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

etow

Hi Hutch,

Here is my complete program with incorrect display of real numbers in my quadratic equation program.  I have included my source code and executable program.

Please look at it and tell me what is wrong so I can correct it.

Thanks

etow

Sorry Hutch I forgot to attach the zip file,

Here is my complete code with executable in the zip file below:



[attachment deleted by admin]

Adamanteus

 You are little mistaken with output function, so all is well working :

[attachment deleted by admin]

etow

What do you mean mistaken by output function?

How come I get integer results instead of floating point numbers?


Adamanteus

 I changed function that you are used String on FpuFLtoA that to output floating point number.
That to get integer result, floating point converting to interger, by sequence of commands FLD - FISTP.
That to discard tail zeros in floating point number string, I myself using special string functions that round remember to given leight and discard the zeros if it is. They are quite difficult and about 500 lines on C, with such prototype : cap_t* strauxrnd (cap_t* str, const short precision, const cap_t pset) (cap_t it's character)

etow

Hi Hutch,
I corrected a preservation of my registers.

Can you tell me why it is not reading the floating point numbers from the edit box?

I have included my code in zip file called QuadraticSolutions5.zip

[attachment deleted by admin]

etow

Hi Hutch,

I modified my code and still my floating point numbers output are not correct.

Please help.

Thanks

[attachment deleted by admin]

hutch--

Egan,

I downloaded the code and had a look at it but its the same problem, I don't use the environment it is built with and I cannot test it. I don't properly know what you are trying to do so I have little chance of making sense of your code.

What I want you to do is put the basic calculations into something simple like a masm32 console app with the required data inputs so I can see what you are trying to do. The idea is to track down what you are doing bit by bit, not as a block of code that is not doing what you want. Try a masm32 console template and put the three floating point numbers to test with in the data section something like,


fp1 REAL10 1234.5678
fp2 REAL10 9876.5432
fp3 REAL10 1928.3847


The idea is to get the calcxulation working properly first then work out how to display it

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

etow

Hi Hutch,

Here is my Win32 console program to solve the quadratic equation in the link below.

This gives you the exact idea of what I want to do in my visual program of QuadraticSolutions.





[attachment deleted by admin]