DECIMAL NUMBER ARITHMATIC

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

DECIMAL NUMBER ARITHMATIC

2,806件の閲覧回数
tballer
Contributor I
I am new to this and am trying to do arithmetic on a decimal number in the following format:
XXX.XXXXXX

The arithmetic will include squaring, taking the square root, dividing and addition and subtraction.  What is the best way to go about this?
ラベル(1)
0 件の賞賛
返信
5 返答(返信)

827件の閲覧回数
JimDon
Senior Contributor III
Depends on what you consider "best".

The easiest way it to use doubles.

0 件の賞賛
返信

827件の閲覧回数
tballer
Contributor I
Is it easy then to square a number, lets say 128.3434434, and put it in memory in a 16 bit microcontroller?
0 件の賞賛
返信

827件の閲覧回数
nikosxan
Contributor I
Using a C compiler for the specific MCU you use will enable you to have variables of float types and supportes also math (multiplication / division / root, even some trigonometry). Also when having variables and a C language enviroment is no problme 'store results' in memory.... However all these ends up with a lot of  code size increase, since float math nedds a lot of code to be implemented, but this should be no major problem if you have decent FLASH memory (eg 64 K or more...). Also, MCUs support integer math internally and up to multiplication / division, so doing a sqrt or a sine is also time consuming compared to sipler 8 / 16 bits math.
 
What's the need for doing such math ?
0 件の賞賛
返信

827件の閲覧回数
nikosxan
Contributor I
...Cont...
 
If you really need do complex math (as float numbers support, sin / cosine, sqrt etc)  the only way to go is use a high level language (mostly C for microcontroller, but also Basic or even pascal could be found)...
0 件の賞賛
返信

827件の閲覧回数
JimDon
Senior Contributor III

You will need to learn the "C" programming language, but yes it is.


0 件の賞賛
返信