PC Review


Reply
Thread Tools Rate Thread

Re: Why does 28.08 show up as 28.080000000000002 in DataGridView

 
 
Mike C#
Guest
Posts: n/a
 
      13th Jan 2007
I think Mr. Skeet has an excellent idea in wrapping up this thread. As
such, I'd like to provide an opposing view to the question which Mr. Skeet
implied early on; in a nutshell: "Why are FLOAT and REAL called
'approximate' types while INT, DECIMAL, etc., types called 'exact'?"

I believe that the following simple definition follows the intent of the
standards put forth by ANSI (SQL), Microsoft (C#, VB, etc.) and other
standards bodies in referring to data types based on the IEEE floating
standards as "approximate" and other data types as "exact":

"Exact data types are those data types which can store and retrieve single
values which conform to the following rules without loss of data, and
without the introduction of error:

1) The value must be composed of digits/characters that are defined as
valid, in the proper format defined for the data type,
2) For numeric types, the scale (digits after the decimal point) of the
value needs to be less than or equal to the scale of the data type,
3) For numeric types, the difference between precision (total number of
digits) and scale of the value needs to be less than or equal to the
difference between the precision and scale of the data type,
4) For numeric types, the value must be greater than or equal to the lower
bound defined for the data type, and less than or equal to the upper bound
defined for the data type,
5) For non-numeric types, the length of the value must be less than or
equal to the length of the data type"

This definition follows the intent of the standards bodies, including their
specification of floating point literals as Base 10. This definition also
accounts for truncation and rounding errors in irrational numbers and
infinitely repeating decimal values since their scale is infinitely beyond
what can be accurately represented by any built-in finite SQL, C#, or VB
types.

While Mr. Skeet also expressed an issue with calling FLOAT and REAL data
types "approximate", these labels are entirely accurate, as they succinctly
express the position that when you try to store a numeric literal that
follows the above rules, an "approximation" of that value may be stored
instead of the "exact" value.

Like Mr. Skeet, I too feel this thread has run its course, and also feel
that arguments about items that have no real world applications or relevance
(quite possibly why they were left outside the scope of the adopted
standards: i.e., "Base 3", etc.) has no real bearing on the issues at hand.
This has been an interesting discussion despite having to deal with side
issues that have no basis in reality, and the ignoring of accepted standards
as well as the intent of the standards bodies in defining these types and in
labeling them as "approximate" or "exact".


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does 28.08 show up as 28.080000000000002 in DataGridView Daniel Manes Microsoft Dot NET Framework Forms 130 13th Jan 2007 08:47 PM
Re: Why does 28.08 show up as 28.080000000000002 in DataGridView Mike C# Microsoft Dot NET 11 13th Jan 2007 07:51 PM
Re: Why does 28.08 show up as 28.080000000000002 in DataGridView Mike C# Microsoft Dot NET 9 13th Jan 2007 06:41 PM
Why does 28.08 show up as 28.080000000000002 in DataGridView Daniel Manes Microsoft Dot NET Framework Forms 1 10th Jan 2007 12:37 AM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger Microsoft ASP .NET 2 2nd Dec 2006 04:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:32 AM.