Is there a vulgar fraction that can be used as a variable?
For example: I want to divide the integers 1 and 3. The result as int
is 0, as double
result is 0,333333333
. However, I want the result to be exactly 1/3
, and later to use it in other equations in the program.
Is there a variable similar to the integer (int
), decimal (double
), e.t.c. (that is being declared and used in a similar way)? Or do I have to make one myself?
At first I was thinking how to make it myself, but I failed.
Thanks!
Not in the core language, but there are libraries, such as boost::Rational.
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