Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] 8051, arithmetic operation of a decimal number (value contains point)

Status
Not open for further replies.

RAHUL_KUMAR

Member level 5
Joined
Jun 5, 2017
Messages
90
Helped
4
Reputation
8
Reaction score
4
Trophy points
8
Location
Bhubaneswar,Odisha,India
Activity points
780
8051 ,arithmetic operation of decimal number (value contains point)

In 8051 , the problem which is aroused is how to do operation of a number contains point.
23/1.085

We can't store the decimal value((like 1.085) in any register . and if we multiply numerator as well as denominator by 1000 ,the result will become more than 16 bit.

any proper solution with minimum number of registers ,to divide the number like 23/1.085 ?
 

Re: 8051 ,arithmetic operation of decimal number (value contains point)

What programming language are you writing in? If you are using a high level language, there is probably a floating point arithmetic library you can use. If you are using assembly language, the simplest method is probably to use 32 bits, it isn't that difficult to do. You could also look at alternative programming strategies, for example, where does the '1.085' come from, if it is an ADC result you might be able to use the value from the ADC registers directly instead of converting to a floating point number.

Brian.
 
Re: 8051 ,arithmetic operation of decimal number (value contains point)

Unless you are designing a pocket calculator, you won't use decimal arithmetic in a microcontroller. Instead you'll translate the decimal factor to a binary fixed point (integer with power of two shift factor) with appropriate resolution. E.g. instead of /1.085 you'll calculate *944/1024.

An arithmetic library is required in any case, either written by yourself or imported. There are also floating point libraries for x51 processor. but 8052 has rather tiny flash, so it may be unsuitable for floating point.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top