There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
C++ float vs. Double


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Fyzbo's Avatar
Senior Member with 1,766 posts.
 
Join Date: Feb 2002
Location: North Carolina, USA
Experience: Programming-Advanced|EVER
05-Mar-2004, 11:58 AM #1
C++ float vs. Double
Can anyone explain the difference between float and double? Also is it possible to have your program not run properly by using one instead of the other?
AlbertB's Avatar
Distinguished Member with 2,432 posts.
 
Join Date: Nov 2002
Location: Hampshire, UK
05-Mar-2004, 12:46 PM #2
A float is defined as being a number of bytes long depending on what implementation you are using. A double is defined as twice that. So the difference is in the range of values they can each hold.

You should find that if there are conflicts between the two in your code you will get warnings flagged, but these are usually to do with possible loss of accuracy.

For most normal purposes float is accurate enough and saves a little memory.
__________________
1. "I make no personal claim to the truth, only the right to seek it, prove it in argument, and to be wrong many times in order to reach it."

2. "We have made a cage of words and placed our God inside, as boys trap a cricket, to make him sing for us alone."

Galileo Galilei
AlbertB's Avatar
Distinguished Member with 2,432 posts.
 
Join Date: Nov 2002
Location: Hampshire, UK
05-Mar-2004, 12:50 PM #3
This is from M$ Vis Studio 6.0 Help file.

Quote:
The floating-point types are float and double, representing the single-precision 32-bit and double-precision 64-bit format IEEE 754 values and operations as specified in IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Standard 754-1985 (IEEE, New York).
There it is, 32 bit precision and 64 bit precision. 64 bit 3D global positioning throughout the Solar System application?
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:09 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.