Continue to Site

Welcome to

Welcome to our site! 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.

converting decimal number to something i can disp

Not open for further replies.


Junior Member level 1
Dec 26, 2005
Reaction score
Trophy points
Activity points

I have a problem converting a decimal number stored in a float variable into something I can display on a 2 x 16 char display.

how do i convert a number like : 0.000000013?.
I have no problem displaying whole numbers on the display.

hope some of the geniuses out there can help me :)
im currently trying to write the code for the AVR platform using imagecraft


Look up Binary Coded Decimal. Imagecraft may have BCD routines already, if not I'm sure there out there as it's a very common thing for people to use.

thx very much, im gonna read a bit about it, and see if i can make it work.


I have been looking at the bcd format as suggested and I must admit I can't see how that's gonna help with my problem.

If I have a number like 12 nano stored in a float variable and want it converted so i can display it on a hdd44780 2x16 char disp.
I can't shift left, for some reason thats not possible on a float, my second idea was to multiply it, but that still presents me with a problem, since my prefiks can change from nano to micro from each mesurement.

any ideas on how to do it, or some way to see what prefiks the number in the float has?

have another question not related to the other one.

if I want to raise a number to the power of i would normally do it like this in C: "10^2", dosent work in imagecraft, then I looked in the math include file, which has this routine:

float powf(float x, float y) )
returns x raised to the power y.

but this dosent return the right value either, i think maybe its something with my varible types, thats screwing around. Has anyone tried to use this routine, and if so, maybe they have an example I can see?



I don't understand why you can't simply multiply the number X 1000 to shift it over, do this until the answer is > 1 and you should have nothing left but 12 on a number like .000012 or 250 on a number like .00000025 for each time you have to multiply it by 1000 the prefix of your measurment can be judge. If you don't have to multiply it at all it's a whole number obviously, if you have to multiply it ocne it's mili, twice it's micro, three times it's nano etc...

uuuhhh you'r one smart guy, great idea thanks :)

if someone can help me with the power of question, my project to measure inductors will soon be a reality..yiiipie !

phoenixdk, why dont you use sprintf() function?

im selftought in c and im beginning to be pretty good at it, but i do have some holes in my knowledge here and there.

f.eks i have never used sprintf function. but im gonna goggle it in a sec :D

Phoenix, I mean no offense, but if you're having trouble with figuring out how to decimal shift a floating point value you are not pretty good at C. The above mentioned simple multiply by 1000 till you have a whole number and then use the number of interations as the units holder is as simple a routine as you will find, and may depending on the stdio.lib implemenation on your partcular microcontroller may be much faster when executing.

for some reason the shl command dosent work in imagecraft (on floats) , just dident occur to me to multiply by a 1000;

Not open for further replies.

Part and Inventory Search

Welcome to