CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2009
    Posts
    18

    Simple C++ question

    How would I code the negative value of an if else function? Would I just have to convert 1 x 10-5 to a decimal value?

    if (x > 1 x 10-5)
    {
    cout << "Value" << endl;
    {
    else

  2. #2
    Join Date
    May 2007
    Posts
    437

    Re: Simple C++ question

    can you eleobrate your problem in more detail
    ashu
    always use code tag

  3. #3
    Join Date
    Feb 2009
    Posts
    18

    Re: Simple C++ question

    Well the complier won't complie past

    if (x > 1 x 10-5)

    Would I have to convert the 1 x 10-5 to a decimal value or is there another way ?

  4. #4
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Simple C++ question

    Quote Originally Posted by Guru_Kid
    Would I have to convert the 1 x 10-5 to a decimal value or is there another way ?
    The expression 1 x 10-5 does not make sense. What exactly are you trying to compare?
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  5. #5
    Join Date
    May 2007
    Posts
    437

    Re: Simple C++ question

    1 x 10-5
    if you want to multiply 10 with 1 and then subtract 5 . then use *

    to get decimal value of 1 x 10-5 can be calculated 1*10-5
    ashu
    always use code tag

  6. #6
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: Simple C++ question

    Quote Originally Posted by Guru_Kid View Post
    Well the complier won't complie past

    if (x > 1 x 10-5)

    Would I have to convert the 1 x 10-5 to a decimal value or is there another way ?
    Looks you are asking about standard form, 1E-5. Read up on floating point numbers, in C++ you can used float or double to store such numbers.
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

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

    Re: Simple C++ question

    Quote Originally Posted by Guru_Kid View Post
    How would I code the negative value of an if else function? Would I just have to convert 1 x 10-5 to a decimal value?

    if (x > 1 x 10-5)
    {
    cout << "Value" << endl;
    {
    else
    It's hard to tell your intent but maybe you mean

    if (x > (1 * (10-5)))

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

    Re: Simple C++ question

    He means 1e-5, I'm fairly sure.

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