This week's book giveaway is in the Cloud/Virtualization forum.We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Liutauras Vilda
• Campbell Ritchie
• Tim Cooke
• Bear Bibeault
• Devaka Cooray
Sheriffs:
• Jeanne Boyarsky
• Knute Snortum
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Ganesh Patekar
• Stephan van Hulst
• Pete Letkeman
• Carey Brown
Bartenders:
• Tim Holloway
• Ron McLeod
• Vijitha Kumara

# double call by reference?

Ranch Hand
Posts: 38
look at this code:

what is the expected output? not what i thought.

Azriel Abramovich
Ranch Hand
Posts: 38
stupid stupid me.
the correct code is:

it returns that d4==d3.
Why?
If d3=1.2e15 or less it returns false.

lowercase baba
Bartender
Posts: 12627
50
doubles don't really store the exact value. when you get to large numbers, like 1.2e15, do you really care about the least significant digits???
1,200,000,000,000,000 vs.
1,200,000,000,000,001
if we were required to care, then the range of floats and doubles would be MUCH smaller.
the non-technical way to describe it (since i can't give the technical one) is that as the numbers get bigger, there are actually gaps between the numbers that ARE represented. Or, you can only have 15 or so significant digits. if you're looking at a number with say 16 digits, the one's place is basically ignored (or assumed to be 0).
if you have a number with 20 digits, the last 5 are assumed to be 0. even if you add 1 to it, it gets sort of rounded off.
does that make sense?