BIGDECIMAL or similar class
I need a lot more precision in my program than doubles can provide. I''d like to use a class that can handle arbitrary lengths and perform almost all operations standard ints can. Anyone have any advice?
TIA,
Avalon
November 09, 2000 07:58 AM
Curiously enough, I was thinking about this exact problem earlier today. The best advise I could give you is to learn how floating-point numbers are structured (which is like scientific notation, I believe), and using assembly probably wouldn''t hurt either. I don''t believe it''ll ever be as fast as standard floating-point types since the processor based floating-point operations are design for numbers of a certain size, but I could be wrong. Here''s an example of what I would probably do.
The danger from computers is not that they will eventually get as smart as men, but that we will meanwhile agree to meet them halfway - Bernard Avishai
class real {private: long int value; char exponent;public: real(); real(val, exp); real(float); real(double); ~real() // operator functions, etc...};
The danger from computers is not that they will eventually get as smart as men, but that we will meanwhile agree to meet them halfway - Bernard Avishai
Curiously enough, I was thinking about this exact problem earlier today. The best advise I could give you is to learn how floating-point numbers are structured (which is like scientific notation, I believe), and using assembly probably wouldn''t hurt either. I don''t believe it''ll ever be as fast as standard floating-point types since the processor based floating-point operations are design for numbers of a certain size, but I could be wrong. Here''s an example of what I would probably do.
The danger from computers is not that they will eventually get as smart as men, but that we will meanwhile agree to meet them halfway - Bernard Avishai
class real {private: long int value; char exponent;public: real(); real(val, exp); real(float); real(double); ~real() // operator functions, etc...};
The danger from computers is not that they will eventually get as smart as men, but that we will meanwhile agree to meet them halfway - Bernard Avishai
<span class="smallfont">That is not dead which can eternal lieAnd with strange aeons even death may die. -- "The Nameless City" - H. P. Lovecraft</span>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement