Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6600781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:40:08+00:00 2026-05-25T18:40:08+00:00

Yesterday I asked why a adding 10 times 0.10 to a double is not

  • 0

Yesterday I asked why a adding 10 times 0.10 to a double is not equal to int 1;

in VB Why (1 = 1) is False

I got an excellent answer. The overview is because:

  • Floating point types and integer types cannot be compared directly, as their binary representations are different.
  • The result of adding 0.1 ten times as a floating point type may well be a value that is close to 1, but not exactly

I can see the reason why now. However, if I do something like:

  Dim d As Double

  For i = 1 To 4
        d = d + 0.25
  Next

  MsgBox(d)  'output 1 
  MsgBox(d = 1) 'True
  MsgBox(1 - d) ' 0
  Console.WriteLine(d) '1

In this case I really obtain equality between double 1.0 and int 1. I thought then that double were only approximations so I would expect d to be somehow a value close to 1 as in the original first question. Why is not a good idea to compare directly different data types (in this case double – integer) and why I this time I obtain equality ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:40:08+00:00Added an answer on May 25, 2026 at 6:40 pm

    Yes, doubles are usually aproximations. But some numbers work better than others.

    Just like decimal numbers: you can write 1/10 exactly (0.1), but not 1/3 (0.33333…).

    So it happens that 1/4 can be converted exactly to a binary floating point number, where 1/10 can’t be.

    EDIT
    A decimal (floating point) numbers works with powers of 10, so if you can write some number as a combination of 1/10, 1/100, 1/1000 etc (multiples allowed) then you can write that number exactly as a decimal number.

    For binary floating point numbers it works the same, only the sequence is 1/2, 1/4, 1/8, 1/16 etc. Plus in computers there is a limit in the precision: some details are just too small to represent exactly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked this question yesterday got a pretty good answer but can't figure out
As an answer to a question I asked yesterday ( New Core Data entity
I asked a question yesterday on here and got some awsome help, but I
So I asked a similar question yesterday, and got a great response - I'm
Yesterday I asked (A case of outwardly equal lists of sets behaving differently under
I asked a question yesterday about namespaces that got answered, and so I tarried
This is based on a question I asked yesterday. It got very muddled, so
Yesterday I asked a question here that got more momentum that what I thought
I asked a question yesterday about a click to reveal menu which got answered
Yesterday I asked this general question about decimals and their internal precisions. Here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.