Click here to Skip to main content
15,908,906 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Replace Item Listbox ? Pin
Briga19-Sep-05 22:23
Briga19-Sep-05 22:23 
GeneralRe: Replace Item Listbox ? Pin
gerrolette20-Sep-05 2:01
gerrolette20-Sep-05 2:01 
GeneralRe: Replace Item Listbox ? Pin
Briga20-Sep-05 6:48
Briga20-Sep-05 6:48 
Questioncombining unicode characters in vb or vbscript Pin
Lanre Ogunkola16-Sep-05 5:20
Lanre Ogunkola16-Sep-05 5:20 
QuestionSingle datatype calculation error Pin
Anonymous16-Sep-05 4:24
Anonymous16-Sep-05 4:24 
AnswerRe: Single datatype calculation error Pin
Dave Kreskowiak16-Sep-05 6:12
mveDave Kreskowiak16-Sep-05 6:12 
QuestionRe: Single datatype calculation error Pin
Anonymous16-Sep-05 10:32
Anonymous16-Sep-05 10:32 
AnswerRe: Single datatype calculation error Pin
Dave Kreskowiak16-Sep-05 12:01
mveDave Kreskowiak16-Sep-05 12:01 
Anonymous wrote:
especially considering that a Single in .NET is capable of 45 decimal places for negative numbers!

I think you're refering to the range of negative 3.402823e38 to positive 3.402823e38. These are the absolute limits of the numbers a Single can approximate. But since it is only 32-bit long, it cannot do it accurately. Under the 754 format, the 32-bit binary representation is actually holding two numbers that fill in an exponent formula that approximates the value you want. This is where the inaccuracy comes from. Since there is limited space to hold these two values, there is very limited precision.

This is by no means the fault of Microsoft and the .NET Framework. This is the standard format that has been used in Intel processors for decades.

There are other number formats that offer greater precision, but eventually, they all suffer from the limitations of binary math using in a finite numerical storage width.

If your doing financial calculations, you have to have a greater understanding of the data types your platform uses (Intel/.NET Framework), what standards those types follow, and what the limitations of those standards and types are. Then you'll be able to select the datatypes and coding techniques that will limit math errors within controlable specifications, if not eliminate them for you, depending on your requirements.

A Single is an IEEE754 32-bit signed value.
A Double is an IEEE754 64-bit signed value.

Here's the scoop on the Decimal type, straight out of the Docs on MSDN:
The Decimal value type is a 128-bit representation of decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335. The Decimal value type is appropriate for financial calculations requiring large numbers of significant integral and fractional digits and no round-off errors.

A decimal number is a signed, fixed-point value consisting of an integral part and an optional fractional part. The integral and fractional parts consist of a series of digits that range from zero to nine (0 to 9), separated by a decimal point symbol.

The binary representation of an instance of Decimal consists of a 1-bit sign, a 96-bit integer number, and a scaling factor used to divide the 96-bit integer and specify what portion of it is a decimal fraction. The scaling factor is implicitly the number 10, raised to an exponent ranging from 0 to 28.

Therefore, the binary representation of a Decimal value is of the form, ((-2^96 to 2^96)/ 10^(0 to 28)), where -2^96 is equal to MinValue, and 2^96 is equal to MaxValue.

What this means is that the Decimal type has the capability to adjusts it's precision to match the requirements of the value. If you have an extremely large number, you usually don't have a need to be accurate to the right of the decimal point. The opposite is also true. For very small numbers, precision to the left of the decimal gives way to precision to the right of it.

I highly suggest reading this[^].


RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

QuestionHow do I embed a database in a VB.NET application Pin
lutherium16-Sep-05 3:34
lutherium16-Sep-05 3:34 
AnswerRe: How do I embed a database in a VB.NET application Pin
No-e16-Sep-05 6:57
No-e16-Sep-05 6:57 
GeneralRe: How do I embed a database in a VB.NET application Pin
seee sharp18-Sep-05 18:08
seee sharp18-Sep-05 18:08 
QuestionWebbrowser in VB.NET Pin
jclaude1316-Sep-05 3:11
jclaude1316-Sep-05 3:11 
AnswerRe: Webbrowser in VB.NET Pin
seee sharp18-Sep-05 18:15
seee sharp18-Sep-05 18:15 
QuestionChannelSecure SiteMinder Pin
Daredeviljpr16-Sep-05 3:09
Daredeviljpr16-Sep-05 3:09 
QuestionSave data when load Pin
16-Sep-05 2:43
suss16-Sep-05 2:43 
AnswerRe: Save in when load Pin
enjoycrack16-Sep-05 2:50
enjoycrack16-Sep-05 2:50 
General[Message Deleted] Pin
Amr M. K.16-Sep-05 2:53
Amr M. K.16-Sep-05 2:53 
GeneralRe: Save in when load Pin
enjoycrack16-Sep-05 3:03
enjoycrack16-Sep-05 3:03 
GeneralRe: Save in when load Pin
Amr M. K.16-Sep-05 3:36
Amr M. K.16-Sep-05 3:36 
GeneralRe: Save in when load Pin
Amr M. K.16-Sep-05 3:37
Amr M. K.16-Sep-05 3:37 
GeneralRe: Save in when load Pin
Dave Kreskowiak16-Sep-05 14:08
mveDave Kreskowiak16-Sep-05 14:08 
GeneralRe: Save in when load Pin
Gopi.V16-Sep-05 23:04
Gopi.V16-Sep-05 23:04 
GeneralRe: Save in when load Pin
Amr M. K.17-Sep-05 9:39
Amr M. K.17-Sep-05 9:39 
GeneralRe: Save in when load Pin
Jerry___18-Sep-05 8:20
Jerry___18-Sep-05 8:20 
GeneralRe: Save in when load Pin
Amr M. K.17-Sep-05 9:38
Amr M. K.17-Sep-05 9:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.