Live data from Hacker News

The fixed_point C++ Class Template

github.com

1–10 of 23 posts

Re: The fixed_point C++ Class Template

#4
post #3

Phew! I was thinking this was going to be a template-meta programming example of a y-combinator... Looks useful!

Yeah, I was prepared to see some Lovecraftesque template metaprogramming implementation of lambda calculus just to calculate the fixed point of a function.

Re: The fixed_point C++ Class Template

#6
I was having trouble understanding why fixed-point arithmetic was particularly useful in game development. In fact, I was curious why fixed point representation was more useful than floating point at all...

Two links deep, I found [1]. The salient being "...floating point representation gives you extra precision for numbers near zero, this extra precision comes at the expense of precision for numbers further out"

1. http://www.pathengine.com/Contents/Overview/FundamentalConce...

Re: The fixed_point C++ Class Template

#8
post #6

I was having trouble understanding why fixed-point arithmetic was particularly useful in game development. In fact, I was curious why fixed point representation was more useful than floating point at all... Two links deep, I found [1]. The salient being "...floating point representation gives you extra precision for numbers near zero, this extra precision comes at the expense of precision for numbers further out" 1.…

Not every architecture has an FPU, and doing floating point in software is obviously pretty slow.

Re: The fixed_point C++ Class Template

#9
post #6

I was having trouble understanding why fixed-point arithmetic was particularly useful in game development. In fact, I was curious why fixed point representation was more useful than floating point at all... Two links deep, I found [1]. The salient being "...floating point representation gives you extra precision for numbers near zero, this extra precision comes at the expense of precision for numbers further out" 1.…

A two-byte fixed-point number is likely to be less expensive to deal with than a two-byte floating-point number. (Promotion and demotion cost is pretty high for small floating-point types (bit masking, shifting, oring, etc.) compared to fixed-point promotion and demotion (shift).)

Re: The fixed_point C++ Class Template

#10
post #9
post #6

I was having trouble understanding why fixed-point arithmetic was particularly useful in game development. In fact, I was curious why fixed point representation was more useful than floating point at all... Two links deep, I found [1]. The salient being "...floating point representation gives you extra precision for numbers near zero, this extra precision comes at the expense of precision for numbers further out" 1.…

A two-byte fixed-point number is likely to be less expensive to deal with than a two-byte floating-point number. (Promotion and demotion cost is pretty high for small floating-point types (bit masking, shifting, oring, etc.) compared to fixed-point promotion and demotion (shift).)

I figured performance came into it also. It would be nice to see some performance numbers though.
Post reply on HN