CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2010
    Posts
    45

    Question Number of decimal places

    Hello,

    In c++, is there a way to determine the number of decimal places that a variable of type "long double" has?

    I'd prefer not to convert to a string to do this (if possible).

    Thanks!

  2. #2
    Join Date
    Aug 2009
    Posts
    219

    Re: Number of decimal places

    maybe u could google for sizeoff(), im not sure since im not fully understanding ur request

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,624

    Re: Number of decimal places

    He's asking for a floating point number such as 23.769, how to determine how many decimal places there are.

    I don't know of a reliable way.

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Number of decimal places

    It has as many decimal places as you ask it to have when you print it out. How many of those are simply trailing 0s....that's another problem.

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Number of decimal places

    You could convert it to a string and simply remove the last zero's.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured