4 ms·
The funny thing is that if you're dealing with (US Treasury) bonds, (EDIT: binary) floats are actually kind-of the right thing, since they trade in 32nds of a d
by andreareina 7y ago
The funny thing is that if you're dealing with (US Treasury) bonds, (EDIT: binary) floats are actually kind-of the right thing, since they trade in 32nds of a dollar (and binary fractions thereof)[1][2]
> Unlike U.S. equity markets, which switched to decimal pricing in 2001, U.S. Treasury securities still trade in fractions. In particular, prices are quoted in 32nds of a point, where a point equals one percent of par, with the 32nds themselves split into fractions. On the BrokerTec platform, for example, 3- and 5-year notes trade in quarters of 32nds, whereas 7-, 10-, and 30-year securities trade in halves of 32nds. The quoted price for a 5-year note might be 98-15¼, for example, indicating a price in decimal form of 98.4765625 (that is, 98 + 15⁄32 + ¼⁄32).
[1] https://www.newyorkfed.org/aboutthefed/fedpoint/fed07.html https://www.newyorkfed.org/aboutthefed/fedpoint/fed07.html
[2] https://www.bloomberg.com/opinion/articles/2020-01-15/it-s-not-insider-trading-if-the-president-does-it https://www.bloomberg.com/opinion/articles/2020-01-15/it-s-n...
- jleahy 7y agoUnfortunately it's 32nds of a 100th, so they still don't work in floats (because floats are stored normalised, as 1.x in binary). Eg. 117.125
- andreareina 7y agoIs it? The NY Fed site says it's 32nds of a dollar: > • Prices are quoted in 32nds of a dollar. > [...] Note and bond prices are quoted in dollars and fractions of a dollar. By market convention, the normal fraction used for Treasury security prices is 1/32.
- jleahy 7y agoRight, but the price is about 100, not 1. If you had a price of 1.25 then you could represent this as a float as (binary) 1.01. However if you have 117.25 then that's (decimal) 1.83203125 * 2^-6. You can see how you quickly run out of bits.
- dragonwriter 7y agoArbitrary precision rationals are the general solution for when some aspects of the calculation work better are in binary (power-of-two denominator) fractions and some are in decimal fractions.