Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating low precision hardware in Java [closed]

I am trying to write a simulator for a hardware device with fairly low numeric precision (preferably in Java), and I am looking for a library that implements elementary mathematical operations.

Specifically, I need a class that implements binary floating point arithmetic, and allows the user to set the precision of both the mantissa and exponent. (Probably 8 or 10 bits for the mantissa, and 6 or 8 bits for the exponent.)

I've looked at a variety of packages intended for high precision arithmetic (Apfloat, jScience, the Dfp class in the Apache Commons package), but they all seem to either have the problem of only supporting radix 10, or they do not allow the user to control the precision of the exponent.

Do you have any suggestions for Java packages that would be a better match for my objective, or advice on how to modify an existing library to do what I want?

like image 921
Mark J Avatar asked May 24 '11 00:05

Mark J


1 Answers

http://real-java.sourceforge.net/Real.html seems to work with base 2, so you may be able to modify it to support a more limited mantissa and exponent range.

like image 139
Dan Berindei Avatar answered Nov 06 '22 18:11

Dan Berindei