Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing a float on a bar code scanner

Status
Not open for further replies.

tomkoff

Programmer
Feb 1, 2002
4
0
0
BE
Hi,

I've to show a float on the screen of a bar code scanner. I've tried to input a float and show this on the screen of the bar code scanner but that doesn't work. Now i've for solution to input an integer (the number with decimals but no decimal sign) and then place this integer in a string. When i put the integer in the string, i've to put the decimal sign so that i have 2 decimals. How can i do this?

Example:

Input 12375 (integer)
Output 123.75 (string)

Can anyone help me?

Thanks
 
int aBarCode = 12375;
printf ("%3d.%2d",aBarCode/100,aBarCode%100);
 
Thanks for the solution, it's almost working, but i have still a problem at the bar code scanner. If i enter the code as above, i've the following printed on my screen of the scanner: 123.

The decimals don't appear on the screen. I've tried to set them in a string and then print them but that doesn't work.

More suggestions??
 
Well you can convert your integer first to string and then manipulate the strings as you like.
You can use the built-int function itoa (abreviation for integer to ascii).
syntax for itoa is:
char * itoa(int value, char *string, int radix)

Well you can read about this function in your C compiler's documentation. I hope this should help your problem.
It's very easy to use this function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top