fixed-point

What's the best way to do fixed-point math? [closed]

半腔热情 提交于 2019-11-26 18:13:06
I need to speed up a program for the Nintendo DS which doesn't have an FPU, so I need to change floating-point math (which is emulated and slow) to fixed-point. How I started was I changed floats to ints and whenever I needed to convert them, I used x>>8 to convert the fixed-point variable x to the actual number and x<<8 to convert to fixed-point. Soon I found out it was impossible to keep track of what needed to be converted and I also realized it would be difficult to change the precision of the numbers (8 in this case.) My question is, how should I make this easier and still fast? Should I

Fixed point math in c#?

穿精又带淫゛_ 提交于 2019-11-26 18:10:19
I was wondering if anyone here knows of any good resources for fixed point math in c#? I've seen things like this ( http://2ddev.72dpiarmy.com/viewtopic.php?id=156 ) and this ( What's the best way to do fixed-point math? ), and a number of discussions about whether decimal is really fixed point or actually floating point (update: responders have confirmed that it's definitely floating point), but I haven't seen a solid C# library for things like calculating cosine and sine. My needs are simple -- I need the basic operators, plus cosine, sine, arctan2, PI... I think that's about it. Maybe sqrt.

Fixed Point Arithmetic in C Programming

邮差的信 提交于 2019-11-26 15:41:34
问题 I am trying to create an application that stores stock prices with high precision. Currently I am using a double to do so. To save up on memory can I use any other data type? I know this has something to do with fixed point arithmetic, but I can't figure it out. 回答1: The idea behind fixed-point arithmetic is that you store the values multiplied by a certain amount, use the multiplied values for all calculus, and divide it by the same amount when you want the result. The purpose of this

storing money amounts in mysql

折月煮酒 提交于 2019-11-26 11:59:34
问题 I want to store 3.50 into a mysql table. I have a float that I store it in, but it stores as 3.5, not 3.50. How can I get it to have the trailing zero? 回答1: Do not store money values as float, use the DECIMAL or NUMERIC type: Documentation for MySQL Numeric Types EDIT & clarification: Float values are vulnerable to rounding errors are they have limited precision so unless you do not care that you only get 9.99 instead of 10.00 you should use DECIMAL/NUMERIC as they are fixed point numbers

C++ fixed point library? [closed]

不羁岁月 提交于 2019-11-26 11:56:37
问题 I am looking for a free C++ fixed point library (Mainly for use with embedded devices, not for arbitrary precision math). Basically, the requirements are: No unnecessary runtime overhead: whatever can be done at compile time, should be done at compile time. Ability to transparently switch code between fixed and floating point, with no inherent overhead. Fixed point math functions. There\'s no much point using fixed point if you need to cast back and forth in order to take a square root. Small

What&#39;s the best way to do fixed-point math? [closed]

ぐ巨炮叔叔 提交于 2019-11-26 06:14:55
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I need to speed up a program for the Nintendo DS which doesn\'t have an FPU, so I need to change floating-point math (which is