Home » Developing U++ » UppHub » New STEM4U package
New STEM4U package [message #53091] |
Tue, 25 February 2020 08:11 |
|
koldo
Messages: 3356 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
Science, technology, engineering, and mathematics involve a huge need of computing.
New Bazaar package STEM4U includes libraries focused to make life easier for those who want to make a better world through science and technology.
From now it begins with a few libraries. However more will be added in the future. You all are invited to support it being part of the authors' list.
One example of library included is Rational, an arbitrary precision rational number
We use computers for doing floating point calculations. However even using 64 bit types, lack of precision in calculations produce inaccuracies that go accumulating over time, thus increasing the error.
For example, lets compute y = 2/1 * 3/2 * 4/3 * ... If done n times, result has to be n.
However, the code implementing this will fail:
double val = 1;
for (double d = 1; d < 100; ++d)
val *= (d+1)/d;
Cout() << "double == 100: " << ((dval == 100) ? "true" : "false") << "\n"; // It returns false!?!?
Rational class solves this drawback implementing an arbitrary precision integer rational number.
Best regards
IƱaki
|
|
|
Goto Forum:
Current Time: Fri Apr 19 21:58:18 CEST 2024
Total time taken to generate the page: 0.03897 seconds
|