Converting floating point to fixed point

后端 未结 6 1845
耶瑟儿~
耶瑟儿~ 2020-12-23 12:13

In C++, what\'s the generic way to convert any floating point value (float) to fixed point (int, 16:16 or 24:8)?

EDIT: For clarification, fixed-poin

6条回答
  •  既然无缘
    2020-12-23 12:52

    I gave the answer to the guy that wrote the best answer, but I really used a related questions code that points here.

    It used templates and was easy to ditch dependencies on the boost lib.

提交回复
热议问题