3 ms·
The title piqued my interest in how to implement rounding of floats, on the bit-fiddling level - certainly not an easy task! Disappointingly though, the article
by svantana 14y ago
The title piqued my interest in how to implement rounding of floats, on the bit-fiddling level - certainly not an easy task! Disappointingly though, the article starts out by using type casting. If it's a solution on that level we're after, why not just use roundf()?
- pascal_cuoq 14y agoIf you feel that using type casting to implement round-to-nearest-integer is cheating, an earlier post is on the subject of implementing a substitute for type casting without type casting. It uses only floating-point arithmetic, but it should still satisfy your curiosity for bit-fiddling. http://blog.frama-c.com/index.php?post/2013/05/01/A-conversionless-conversion-function2 http://blog.frama-c.com/index.php?post/2013/05/01/A-conversi...
- deleted 14y ago[deleted]
- pascal_cuoq 14y agoBy popular demand, a low-level solution: http://blog.frama-c.com/index.php?post/2013/05/03/nearbyintf2 http://blog.frama-c.com/index.php?post/2013/05/03/nearbyintf...