CppCon 2016: John McFarlane “fixed_point'

preview_player
Показать описание


This presentation describes the necessity, utility and usage for a library of safe integer types. These types function in all respects the same way as built-in integers, but guarantee that no integer expression will return an incorrect result. The library can be reviewed at the boost library incubator.

John McFarlane
Programmer
John McFarlane has used C++ for twenty years, specializing in simulation, AI and interactivity. He is a contributor to Study Groups 6 and 14 and is involved in standardizing fixed-point arithmetic.


*-----*
*--*
*-----*
Рекомендации по теме
Комментарии
Автор

I think it's easier to understand what's with the exponent if you apply a resolution term. So a fixed_point<uint8_t, -4> means that the resolution of data type is 2^-4 = 0.0625, that means that each bit in this datatype is multiple of resolution. As another example fixed_point<int16_t, -5> will cover the range [-1024..1023.96875] with resolution 0.03125.
Also it wasn't mentioned that in compile time/constexpr contexts only resulting value is stored, all calculations are done at compile time, e.g. returning (fixed_point<uint8_t, -4>{1.2} + fixed_point<uint8_t, -5>{1}).data() will return just 70.

courier