Home:ALL Converter>How to do fixed-point math instead of floating-point?

How to do fixed-point math instead of floating-point?

Ask Time:2011-04-01T17:15:06         Author:Proud Member

Json Formatter

I'm not the math uncle, but a real one told me this:

"use fixed point instead of floating point to do multiplication, division, summation, trigonometry and integration"

So instead of using double or float data types, what shall I do? Does anyone have a handy snippet or link that shows the difference for non-math-uncles?

Author:Proud Member,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/5511372/how-to-do-fixed-point-math-instead-of-floating-point
Jhaliya - Praveen Sharma :

Check the below for link for fixed point, I'm sure will be useful for you ...\n\nhttp://cnx.org/content/m11054/latest/\n\nhttp://www.digitalsignallabs.com/fp.pdf",
2011-04-01T09:23:22
Lindydancer :

The language itself does not support anything except integers and floating-point values. However, you can easily simulate fix-point values by integers. If you, for example, decide that you want a fix-point value with three decimals, you can use, for example 12345 to represent 12.345. Addition is straight forward, and you can surely work out how to express the other basic operations.\n\nHowever, there is no support for doing trigonometry etc.",
2011-04-01T09:21:34
yy