CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 21

Threaded View

  1. #1
    Join Date
    Aug 2006
    Posts
    515

    .11 * 100 trouble in C++

    My float variable contain .11 and I don't get the desired result of 11 from multiplication but simply numerica value .11 works.
    Code:
    short int test = .11 * 100; // test is right 11.
    
    // case 2
    float fVal = .11;
    short int test = fVal * 100; // now test is .10
    I tried various typcasting but it always is .10 when I use the float variable. How can I get the correct result?

    updated:
    compiler is VC++ 2005
    Last edited by zspirit; April 27th, 2007 at 11:59 AM.

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