Post Reply 
Decimal floating point to binary floating point
12-26-2018, 11:14 AM
Post: #7
RE: Decimal floating point to binary floating point
(12-26-2018 07:10 AM)Dan Wrote:  Perhaps a look-up table, storing m * 2^n, where m,n satisfy m * 2^n = 1.25^N for N element [-99,99].

What exactly are you trying to gain by using \(1.25^N\) instead of \(10^N\)?
The mantissa in binary is the same, but now you have to deal additionally with powers of 8.

(12-26-2018 08:46 AM)Dan Wrote:  The libraries are great, but I like the control and learning I get from writing the routines, even though they won't be as good as the ones written by the pros.

Reading the source code of the libraries can be inspiring. You may wonder why they chose that mixed approach with two look-up tables in Java. Was it about keeping the size of the classes small? Or was it a premature optimization?

Thanks for leading me down the rabbit hole with your question. I learned a lot of new stuff: the fast path mentioned by Albert, or that casts from integer types to floating-point types are handled by the VM (i2d or l2d) or machine code (cvtsi2sdl or cvtsi2sdq).
Unfortunately Wikipedia does a bad job explaining converting from decimal representation to binary32 format.

Kind regards
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: Decimal floating point to binary floating point - Thomas Klemm - 12-26-2018 11:14 AM

User(s) browsing this thread: 1 Guest(s)