Hacker News new | ask | show | jobs
by inamberclad 743 days ago
Once more, this is _exactly_ why Ada has arbitrary precision decimal arithmetic. One merely needs to specify

type Result is range -100 .. 100 delta 0.0001;

and the compiler will figure out how to give you fast math with only the accuracy and resolution that you need!

2 comments

How does that feature work without a solution to the tablemaker's dilemma? Does the compiler just give up and give you arbitrary precision every time you use transcendentals or does it give up and use lower precision if the estimate exceeds some arbitrary bound?
Looking at the spec [0], it only demands 1 ULP of precision for the elementary operations, and 2, 4, or 8 ULPs for special functions. So there's no magic 1/2-ULP guarantee.

[0] http://ada-auth.org/standards/22rm/html/RM-G-2-3.html

have you tested this? how fast and accurate were the results? or are you simply assuming that all compilers are perfect?

my experience outside of ada is that decimal arithmetic is never fast on binary computers

aaui that Ada line would declare a fixed-point type, so decimal/binary shouldn't really come up except for overflow handling, here. (Haven't tried it though.)