Thread: floating point to string

  1. #1
    Registered User
    Join Date
    Jul 2003

    floating point to string

    hi, do you convert flaoting pointing number to string without using sprintf() function

    2. suppose there is one floating point number 1000.0001 how would you count number of zero's in the number without converting number into string.
    thanx in advance.
    eagerly expecting ur ans

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Some compilers defines a non-standard atof() function. Does yours?

    Because you're dealing with digital data, you can never be sure if your value is 1000.0001 or 1000.0001000001 or not. All you can do is display the appropriate number of decimals.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User
    Join Date
    Jul 2003
    I have used one function which gives you integer part and decimal part. But I dont remember function name. You can use that function to split integer and fractional part. Then the job becomes so easy to convert int to string. The above is the answer for first question.
    For second question again use integer and fractional part to determine the No. of zero's. In fractional part mulitply the number with 10 till you get a number greater than 0 and apply the logic that you have applied for integer part.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Testing Floating Point Return Values
    By jason_m in forum C Programming
    Replies: 5
    Last Post: 08-15-2008, 01:37 PM
  4. String and Floating Point Conversion Help
    By dfghjk in forum C++ Programming
    Replies: 14
    Last Post: 05-04-2008, 12:11 PM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM