View Single Post
Old 26 December 2022, 23:56   #22
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,588
Quote:
Originally Posted by meynaf View Post
This is because it can not really be 'right'. Contrary to integer, float does not provide exactness.
Results of calculations may not be 'right', but displaying a floating point literal in decimal should be. The binary floating point format is not ambiguous so the display in decimal should not be either.

Ideally I want a decimal fp number that compiles to the same binary value as it was converted from. Unfortunately this relies not only on converting it to decimal 'correctly', but also on the compiler or assembler doing the 'correct' conversion the other way, which in my case (ProAsm) it doesn't (you can input several slightly but significantly different 80 bit fp numbers and they come out the same).

This problem is 'solved' by using hex fp literals. However for most purposes I am happy enough getting back what was typed into the original source code, eg. 1000.0 disassembles as 1.0E3, not 9.9999986E2. That's why I round. It's more likely that the original number was 1000 than 999.999??.
Bruce Abbott is offline  
 
Page generated in 0.04417 seconds with 11 queries