LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-01-2007, 09:04 PM   #1
ArlexBee-871RBO
LQ Newbie
 
Registered: Mar 2007
Distribution: Gentoo
Posts: 3

Rep: Reputation: 0
C++ floats and doubles


Hello.

I'm using Kdevelop(g++) on an Athlon XP system.
On my system float is 4 bytes, double 8 bytes, and long double 12 bytes. I used numeric_limits<T>::min() and numeric_limits<T>::max() to get the maximum and minimum finite value. For float MINIMUM value = 0.000000 and MAXIMUM value = 340282346638528859811704183484516925440.000000. For double and long double fo course the values are larger.

Now my question is, why can't I assign a value from within the minimum and maximum range to a variable of any of those types? Say, float X = 466385288598117041834 gives me an error.

I could do cin >> X and enter '466385288598117041834', but then cout << X returns '466385283139233644544.000000', which isn't accurate.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question About Floats and Doubles gomez6211 Programming 3 09-13-2006 07:47 PM
Perl, integer and floats ivanatora Programming 2 04-06-2005 05:09 PM
byte swapping for floats hypnoticSpectre Programming 1 11-08-2004 10:48 PM
STL vector of 3 doubles? true_atlantis Programming 2 04-22-2004 10:13 AM
How to display formatted floats rkrijger Linux - Software 4 10-21-2003 08:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration