As a personal project, I am writing a compiler for my own C-like language to orient the processor emulator of my own design.
As part of this, I want to implement a standard floating point library (typical IEEE single precision), but I'm struggling to come up with a way to print the floats in a readable way (like in 1.2345 and not an integer of raw data), the best I I thought - this is to generate values โโfor log 10 2 and do some odd multiplications to get a number in a suitable form for printing. A.
Is there an algorithm for converting a float into an easily printable form or for printing a float that can be implemented without using printf("%f",float_value); or like castings in a C-like language?
c decimal floating-point algorithm low-level
Xandros
source share