Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
i want to know real value multiplication
for example 2.5*2.5 =6.25
1. i multiply 25*25
2. then the result is divide by 100
3.but how can i get the fraction part(.25)
if any body know the logic plz send it
i want to know real value multiplication
for example 2.5*2.5 =6.25
1. i multiply 25*25
2. then the result is divide by 100
3.but how can i get the fraction part(.25)
if any body know the logic plz send it
You don't mention what processor you want it for, but generally micro-controllers aren't good at floating point maths.
Are you wanting general purpose floating point routines?, or is the specific example you gave the only sort of calculations you need?. If so, by careful scaling you can easily perform it with integer calculations and insert the decimal point when you display it.
For example, 2.5*2.5 - scale this to 25*25, giving 625 then just insert the decimal point between the 6 and the 2.
This is commonly done in PC calculations as well, although floating point routines are available in PC high level languages, the way they work could easily give the answer to 2.5*2.5 as 6.249863786936 (or something silmilar). It's often simpler to scale the values, rather than deal with the extra digits - generally money calculations would be performed as integers, for this very reason.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.