I have been working with C/C++ for quite a few years. I have also worked with few other programming languages but none have built-in fractional datatypes. Here I am not talking about the regular decimal datatypes like float. I am referring to regular mathematical fractions having the following form:
Nr/Dr where Dr≠0
What are the challenges that are faced by the developers in implementing such datatypes?
Builtin data types tend to be those that are widely useful, and map more or less efficiently to the underlying architecture. This is no hard and fast rule, but it’s a pretty good rule of thumb.
Fractional data types are neither: they would be widely useful, but limited-precision floating-point types are good enough for 99.9% (or 999/1000, if you prefer) of applications, can be implemented much more efficiently due to hardware support, and have far fewer theoretical and practical limitations because they represent a more general domain of numbers (i.e. not just operations on rational numbers).
There are specific applications where floating point data types don’t cut it, and where arbitrary-precision rational numbers are needed. For those cases, special libraries exist. Cluttering standard libraries with these types would be a waste of effort.
So, essentially, the answer is the same as for any other specialised data type that isn’t widely implemented as a built-in type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With