Post Reply 
Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
02-24-2014, 12:09 AM (This post was last modified: 02-24-2014 12:16 AM by Thomas Okken.)
Post: #1
Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
Hi all,

I'm working on replacing the BCD20 floating-point library in Free42 Decimal with the Intel Decimal Floating-Point Math Library.

Link: http://software.intel.com/en-us/articles...th-library
Link to Free42 for those who don't know what I'm talking about: http://thomasokken.com/free42/

I currently have this running on 32-bit and 64-bit Linux, and expect to have it working for Windows and OS X next weekend (March 1 or 2), if not sooner. Android will follow soon after; iOS will take a bit longer because I have to make some non-floating-point-related changes to add proper support for the iPhone 5's larger screen, since Apple will no longer accept apps without such support.

The new floating-point library has a slightly smaller dynamic range than BCD20 (exponents between a little under -6000 and a little over +6000, as opposed to -10000 through +9999), but it has 34-digit precision, up from 25 in BCD20, and it supports denormal numbers and unbiased rounding.

I haven't done any performance tests yet, but I expect the new library to be faster, since it stores numbers in a more efficient format.

If anyone is interested in playing with this before the official release, drop me a line and I'll send you the 32-bit and/or 64-bit Linux build, or any of the others as soon as I am able to build them -- or the source code, for anyone who would like to take a swing at building it themselves.

Cheers!

- Thomas
Find all posts by this user
Quote this message in a reply
02-24-2014, 01:47 AM
Post: #2
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
Nice work. Just out of interest, what do you use for the mathematical functions?
I know you had you own implementations of many but I don't know how well they'd have come forward to the wider floats.


- Pauli
Find all posts by this user
Quote this message in a reply
02-24-2014, 02:33 AM (This post was last modified: 02-24-2014 02:47 AM by Thomas Okken.)
Post: #3
RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview?
(02-24-2014 01:47 AM)Paul Dale Wrote:  Nice work. Just out of interest, what do you use for the mathematical functions?
I know you had you own implementations of many but I don't know how well they'd have come forward to the wider floats.


- Pauli

The Intel library provides all the functions Free42 needs; it doesn't just have arithmetic and square root, but also trigonometrics, hyperbolics, logarithms, and gamma. The new code uses all of these wherever possible, using the highest-precision format, decimal128.

The higher-level functionality, like complex numbers, matrices, numerical integration, and numerical root-finding, is still done using the same algorithms and code as before, but everything now uses the new library for the basic operations underneath.

In Free42 1.4, the first release that supported decimal floating-point, I basically replaced all occurrences of the C/C++ "double" type with "phloat" (silly, I know), which, in the binary builds, is #defined as "double", and in the decimal builds, is #defined as "Phloat" (note the capital P), which in turn is a C++ class that implements all the necessary constructors, assignment operators, and other operators and friend functions, so that it can be used as a drop-in replacement for plain "double". All the BCD20 stuff was abstracted away by the Phloat class, and the new Free42 code basically just has a new Phloat that uses the Intel library underneath. There have been some changes to the binary/decimal conversion and display code, but that's about it.

- Thomas
Find all posts by this user
Quote this message in a reply
02-24-2014, 06:45 AM
Post: #4
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
I can hardly wait! For the Windows and iOS versions ;-)
Werner
Find all posts by this user
Quote this message in a reply
02-24-2014, 06:55 AM
Post: #5
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview
I'm interested in the Windows version. There's some free test capacity as long as day X hasn't come yet.

d:-)
Find all posts by this user
Quote this message in a reply
02-24-2014, 07:07 AM
Post: #6
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
I would be interested in the 64-bit Linux version.
Find all posts by this user
Quote this message in a reply
02-24-2014, 12:51 PM
Post: #7
RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview?
OK, I have put up the Linux builds.

Link: http://thomasokken.com/free42/download/intel-decimal/

I will try to build the Windows version and upload it tonight, other versions to follow. I will post follow-ups to this thread as additional versions become available.

- Thomas
Find all posts by this user
Quote this message in a reply
02-24-2014, 06:44 PM
Post: #8
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
This is so nice, very nice work indeed
Find all posts by this user
Quote this message in a reply
02-24-2014, 07:54 PM
Post: #9
RE: Free42 with IEEE 754-2008 decimal floating-point
(02-24-2014 12:09 AM)Thomas Okken Wrote:  but it has 34-digit precision
Is there a place where you want us to report bugs?

Example:
1E-34
1 +
1 -

Result:
0.0000E-34

Expected:
0.0000


Thank you very much for your effort.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
02-24-2014, 08:41 PM
Post: #10
Addendum: Free42 with IEEE 754-2008 decimal floating-point
Quote:Because the significand is not normalized, most values with less than 34 significant digits have multiple possible representations; 1×102=0.1×103=0.01×104, etc. Zero has 12288 possible representations (24576 if you include both signed zeros).
Thus maybe not a bug. Still strange. I'd definitely recommend to normalize the results.
Find all posts by this user
Quote this message in a reply
02-24-2014, 10:12 PM
Post: #11
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
I hit the non-unique representation problem in the 34S. I don't remember how I solved it for display any more. Multiple representations of zero caused other issues -- we couldn't just zero registers with a memory clear until after some code was added to detect this form of zero. In integer mode, a memory clear was the way to zero registers...


- Pauli
Find all posts by this user
Quote this message in a reply
02-25-2014, 12:10 AM
Post: #12
RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview?
(02-24-2014 07:54 PM)Thomas Klemm Wrote:  Is there a place where you want us to report bugs?

You can use this thread, or the Free42 forum, or email me.

Link to Free42 forum: http://groups.google.com/group/free42discuss
My email: thomas_okken@yahoo.com

(02-24-2014 07:54 PM)Thomas Klemm Wrote:  1E-34
1 +
1 -

Result:
0.0000E-34

Expected:
0.0000

This appears to be a quirk in the bid128_to_string() function in the Intel library. Numerically, there doesn't appear to be a problem: these zeroes with nonzero exponents do compare equal to regular zero and to each other.

I added a couple of lines in the display code, to make it ignore the exponent when the mantissa is zero; the updated code is on my web site now, under the same URL as before.

- Thomas
Find all posts by this user
Quote this message in a reply
02-25-2014, 12:19 AM
Post: #13
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
The Windows build is going to take a bit longer than I thought. The Intel code won't compile in Visual C++ 6.0, so I may have to go back to VC++ 2010 or 2012. That means more work for me, and possibly the end of XP support. Argh! More tomorrow...
Find all posts by this user
Quote this message in a reply
02-25-2014, 07:31 AM
Post: #14
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
(02-25-2014 12:19 AM)Thomas Okken Wrote:  and possibly the end of XP support.

XP is doomed anyway: -42 and counting.

:)

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
02-25-2014, 09:51 PM
Post: #15
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
(02-25-2014 12:19 AM)Thomas Okken Wrote:  The Intel code won't compile in Visual C++ 6.0, so I may have to go back to VC++ 2010 or 2012. That means more work for me, and possibly the end of XP support.
Don't worry, XP is no problem, at least with VC++ 2010.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
02-26-2014, 12:22 AM (This post was last modified: 02-26-2014 01:42 AM by Thomas Okken.)
Post: #16
RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview?
(02-25-2014 09:51 PM)Marcus von Cube Wrote:  
(02-25-2014 12:19 AM)Thomas Okken Wrote:  The Intel code won't compile in Visual C++ 6.0, so I may have to go back to VC++ 2010 or 2012. That means more work for me, and possibly the end of XP support.
Don't worry, XP is no problem, at least with VC++ 2010.

That's good to know. I'll try that then; if it compiles the Intel code, I should be good to go. Thanks for the tip!
Find all posts by this user
Quote this message in a reply
02-26-2014, 12:42 AM
Post: #17
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
I had a bit of a poke around the Intel Decimal Floating-Point Math Library last night hoping to find a faster implementation of logarithms for the 34S firmware. Lots of large tables and relatively straightforward functions. I suspect that this will be fast and large -- suitable for desktop PCs but not so good for handheld devices. Oh well.

- Pauli
Find all posts by this user
Quote this message in a reply
02-26-2014, 01:20 AM
Post: #18
RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview?
(02-26-2014 12:42 AM)Paul Dale Wrote:  I had a bit of a poke around the Intel Decimal Floating-Point Math Library last night hoping to find a faster implementation of logarithms for the 34S firmware. Lots of large tables and relatively straightforward functions. I suspect that this will be fast and large -- suitable for desktop PCs but not so good for handheld devices. Oh well.

- Pauli

It's certainly a lot larger than BCD20. The Free42 executables are gaining a lot of weight!
The Linux builds of the library for x86 and amd64 are around 6 megabytes; about 5.5 MB for amd64 and 7 MB for x86. I haven't tried building it for ARM yet, but I expect something close to that higher number.
Not something I would have wanted to use on 68k Palm devices... but on iOS or Android smartphones, no problem.
Find all posts by this user
Quote this message in a reply
02-26-2014, 04:18 AM
Post: #19
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
The code didn't seem to support ARM out of the box. I couldn't be bothered added the defines to make it do so. It will be quite a bit larger on ARM than x86 and probably a bit larger even using THUMB (which the 34S does).

Better increase the flash size on the 43S so it will fit Smile


- Pauli
Find all posts by this user
Quote this message in a reply
02-26-2014, 10:15 AM
Post: #20
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview?
Poking around some more and this decimal maths library requires a large amount of binary support too -- supporting both probably wouldn't include much, if any, extra library code.


- Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 




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