Page 1 of 1

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 29th, 2012, 11:36 am
by Y0da
Do quants tend to use any high precision arithmetic libraries in C++ (in order to prevent things like rounding errors, and other floating point problems)? Or do they just trust that double will always work fine?If the former, can you recommend some good high precision libraries out there for C++? In your experience, what are the tradeoffs in terms of performance?For further information: en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 29th, 2012, 12:18 pm
by Cuchulainn
In numerical analysis, you first try to design algorithms so that you don't get rounding errors but this is less of an issues with current technology using 32 and 64 bit doubles (compare this with olde days of doing it with 4-bit floats).BIGNUM stuff is probably a performance hit but I suppose it's trade-off between performance and accuracy. Computations with rational numbers could be useful.And Interval Arithmetic is used in Numerics but is not well-known. //Do you have a specific application in mind or is a general ballpark question?

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 29th, 2012, 12:24 pm
by Polter

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 29th, 2012, 11:25 pm
by OOglesby
As an engineer/programmer and not a quant, I have found that many cases sufficient accuracy can be obtained using doubles or even floats. Many accuracy problems can be solved be changing the order of operations, grouping different quantities together, or reversing loops to sum smallest to largest values. I have developed physics simulations that use both very large (1e9 to 1e15) numbers and very small numbers (1e-17 to 1e-6) using double precession arithmetic.The blog that Polter linked to is a very good resource for learning how to code and preserve as much accuracy as possible. Another good resource is: What Every Computer Scientist Should Know About Floating Point Arithmetic

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 30th, 2012, 2:17 pm
by stonybrooknick
Most Quant's stick to single precision,atleast where i worked... other places they will just declare everything double

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 30th, 2012, 3:02 pm
by daveangel
QuoteOriginally posted by: CuchulainnIn numerical analysis, you first try to design algorithms so that you don't get rounding errors but this is less of an issues with current technology using 32 and 64 bit doubles (compare this with olde days of doing it with 4-bit floats).When did we ever use 4bits for a float ? It must be impossible to store a mantinssa and an exponent in 4 bits !

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 30th, 2012, 5:07 pm
by Cuchulainn
QuoteOriginally posted by: daveangelQuoteOriginally posted by: CuchulainnIn numerical analysis, you first try to design algorithms so that you don't get rounding errors but this is less of an issues with current technology using 32 and 64 bit doubles (compare this with olde days of doing it with 4-bit floats).When did we ever use 4bits for a float ? It must be impossible to store a mantinssa and an exponent in 4 bits !You are right.I was thinking about 4-figure floating-decimal arithmetic which lead to ill-conditioned system long ag (and it was my 60th birthday yesterday).This is a flashback when you had to explicitly model round-off errors!http://books.google.nl/books/about/Comp ... edir_esc=y

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 30th, 2012, 9:40 pm
by DevonFangs
Frankly, never seen anything but doubles nor necessity to go up in precision.

Do quants use high precision arithmetic in C++, or do they just stick to doubles?

Posted: August 31st, 2012, 8:43 am
by Cuchulainn
Things can become nasty with recurrence relations involving 0 - 0, 1 +- 0, 0/0 etc, when bits start falling off the radar screen.