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

    Doubles and Ghost-Decimals



    Compute the following (it's an example, other numbers do the same) :

    346.48 - 346

    The result may not compare with the user-input value 0.48 :


    because 346.48 - 346 does not give 0.48 but something like 0.48000000000018 (not sure for how much zeros)...


    any comment/idea ?

  2. #2
    Join Date
    Dec 1998
    Posts
    5

    Re: Doubles and Ghost-Decimals



    Hi

    If you convert the result to a single with CSng() the result will be 0.48, so the comparison will be fine.

    I've tested it with some other values too, and it worked fine with me.


    Hope this helps


    Crazy D



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