Wouldn't it be much easier if languages allowed storing numbers as fractions?
I know this is a bit hypothetical but I am wondering why no language I know does it.

For example, you want to store 1/3. Give the programmer an option to specify it as 1/3, and store 1 and 3. Something like

    struct float {
        int numerator;
        int denominator;
    };

Real number arithmetic becomes really easy and considerably more accurate!

This would solve so many problems related to the precision and storage limitations of floating point numbers, and I dont see it introducing any new problems as well!

Hence my question: **Why aren't real numbers implemented and stored as fractions with zero loss of information?**

----

As Joe asked, and others might also point out, I do not mean this to replace existing system, but to complement it.

Q: How do you store `pi`?

A: So many times, I am just storing `1/3` and not `pi`. `pi` can be stored the old way, and `1/3` in the new way.
Wouldn't it be much easier if languages allowed storing numbers as fractions?
===

I know this is a bit hypothetical but I am wondering why no language I know does it.

For example, you want to store 1/3. Give the programmer an option to specify it as 1/3, and store 1 and 3. Something like

    struct float {
        int numerator;
        int denominator;
    };

Real number arithmetic becomes really easy and considerably more accurate!

This would solve so many problems related to the precision and storage limitations of floating point numbers, and I dont see it introducing any new problems as well!

Hence my question: **Why aren't real numbers implemented and stored as fractions with zero loss of information?**

----

As Joe asked, and others might also point out, I do not mean this to replace existing system, but to complement it.

Q: How do you store `pi`?

A: So many times, I am just storing `1/3` and not `pi`. `pi` can be stored the old way, and `1/3` in the new way.