I’ve implemented a few core arithmetic operations in a way that (hopefully) accurately emulates TI’s particular float format.

It’s available as a rust crate (which I now realize needs to have its metadata updated) and on github.

Contributions and suggestions are welcome but of course not expected; I was so focused on getting it working that it’s a bit of a mess right now.
This is interesting in that I've looked into doing this in the past for high-level emulation but never could be bothered to go about doing a whole reimplementation. In a thing I wrote targeting TI float operations (that I haven't yet published anywhere) I've been using IEEE decimal floats, since a decimal128 has greater precision than a TI-float so it's easy to truncate between operations.

The tricky part I've found is in actually implementing assorted algorithms in the same way as TI, since the internals of many functions aren't documented anywhere. For example, I spent some time exploring the limits of trig functions to determine their precise behavior and other elementary functions (logarithms, roots..) have similar complexities if you're targeting precisely-copied behavior.
That’s some helpful research- thank you for pointing me to that, I would have missed it otherwise. Precisely-copied behavior is indeed the goal; I was lucky that merely following common-sense for these arithmetical operations matched what I observed exactly.
Unrelated to the mechanics, I also have some comments on your Rust style.
• I'd prefer to call Float::repr Float::from_raw_bytes and the opposite operation to_raw_bytes, since that better expresses what the conversion is.
• TIFloat::negate seems like it would be more nicely expressed as requiring an implementation of std::ops::Neg (trait TIFloat: Ord + Neg)
• Similar to negation, try_add and friends can be expressed as implementation of std::ops::Add (and so forth) with Output = Result<Self, FloatError>, which also lets you naturally have implementations of those operations for built-in types which can be added to a TI-float with maximum accuracy, like impl Add<i8> for Float

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum