Karthik Agarwal

Karthik Agarwal

  • NA
  • 748
  • 265.5k

How to eliminate leading zeros in a number?

Dec 28 2011 12:22 AM
Hi,

I want to know how to eliminate leading zero's in a number using macros.
for example if i give XX.XX then this means that any number can occupy X which will be sent by the application dynamically. if the application sends 1234 then the number i will showing is 12.34 where as if the application sends 12 then i should show 0.12 here i should eliminate the leading zero. similarly if i get 1 then the value should be 0.01. That means i should eliminate all the leading zero's before decimal point except the units decimal point. Which should be done using macro. if the macro is defined i should eliminate zero's if not i should not eliminate. If the value doesn't contain any decimal point like XXXX or XX or XXX or X what ever then i should eliminate all the leading zero's what ever the number may be.

Note: i need pure C coding.

Answers (8)