T
thirtyseven
I was wondering if anyone knew of some public code for a c++ class that
represents a value, but can preserve fractions and powers and such
without just turning the value into a float.
Hard to explain without an example...
I want a class that I can assign a value of (1 + sqrt(5)) to, but it
will keep this "exact" value symbolically... so when I multiply this
value by itself, it will now internally be stored as (6 + 2*sqrt(5))
(and can of course print itself in symbolic format when requested)
I made a fraction class already that internally stores a numerator and
a denominator. So you could store a variable like 3/7, then add it to
another of 5/14, and it would then be 11/14.
So I want to make this new class that's even better at keeping an exact
form, but I figured I'd ask if anyone knows of any similar projects out
there.
Thanks.
- 37
represents a value, but can preserve fractions and powers and such
without just turning the value into a float.
Hard to explain without an example...
I want a class that I can assign a value of (1 + sqrt(5)) to, but it
will keep this "exact" value symbolically... so when I multiply this
value by itself, it will now internally be stored as (6 + 2*sqrt(5))
(and can of course print itself in symbolic format when requested)
I made a fraction class already that internally stores a numerator and
a denominator. So you could store a variable like 3/7, then add it to
another of 5/14, and it would then be 11/14.
So I want to make this new class that's even better at keeping an exact
form, but I figured I'd ask if anyone knows of any similar projects out
there.
Thanks.
- 37