▲ 675 ▼ "Do your own research" they say. (lemmy.world) submitted 2 years ago by FauxPseudo@lemmy.world to c/skeptic@lemmy.world 100 comments fedilink hide all child comments
[–] cynar@lemmy.world 16 points 2 years ago (2 children) For those confused 2.25+2.25=4.5 rounds to 2+2=5 2.5+2.5=5 truncates to 2+2=5 Both can crop up in programming, depending on the situation. permalink fedilink source parent hideshow 4 child comments replies: [–] echodot@feddit.uk 3 points 2 years ago (1 child) 2.25 + 2.25 = 4.5 If you add two floats together then the output is a float, if you add an int and a float together the output is a float. Computers will always perform the calculation as is, unless you explicitly tell them to perform a rounding operation. permalink fedilink source parent hideshow 2 child comments replies: [–] cynar@lemmy.world 6 points 2 years ago However, if you stuff them into an int at the last minute, you can get that effect. Under the hood, it's floats. On the output, it's ints. It's obvious and silly with small examples. The problem can creep in when you are using larger libraries or frameworks. permalink fedilink source parent [–] afraid_of_zombies@lemmy.world 0 points 2 years ago A few months back I had a floating point that had a single 1 like 16 digits past the decimal place and I couldn't get rid of it. permalink fedilink source parent
[–] echodot@feddit.uk 3 points 2 years ago (1 child) 2.25 + 2.25 = 4.5 If you add two floats together then the output is a float, if you add an int and a float together the output is a float. Computers will always perform the calculation as is, unless you explicitly tell them to perform a rounding operation. permalink fedilink source parent hideshow 2 child comments replies: [–] cynar@lemmy.world 6 points 2 years ago However, if you stuff them into an int at the last minute, you can get that effect. Under the hood, it's floats. On the output, it's ints. It's obvious and silly with small examples. The problem can creep in when you are using larger libraries or frameworks. permalink fedilink source parent
[–] cynar@lemmy.world 6 points 2 years ago However, if you stuff them into an int at the last minute, you can get that effect. Under the hood, it's floats. On the output, it's ints. It's obvious and silly with small examples. The problem can creep in when you are using larger libraries or frameworks. permalink fedilink source parent
[–] afraid_of_zombies@lemmy.world 0 points 2 years ago A few months back I had a floating point that had a single 1 like 16 digits past the decimal place and I couldn't get rid of it. permalink fedilink source parent