Click here to Skip to main content
16,016,140 members
Home / Discussions / C#
   

C#

 
GeneralRe: float calculation issue Pin
George_George4-Jun-08 23:28
George_George4-Jun-08 23:28 
AnswerRe: float calculation issue (decimal is no solution) [modified] Pin
The Nightcoder28-May-08 23:12
The Nightcoder28-May-08 23:12 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George31-May-08 3:28
George_George31-May-08 3:28 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder2-Jun-08 3:02
The Nightcoder2-Jun-08 3:02 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George3-Jun-08 2:09
George_George3-Jun-08 2:09 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder3-Jun-08 2:48
The Nightcoder3-Jun-08 2:48 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George3-Jun-08 3:00
George_George3-Jun-08 3:00 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder3-Jun-08 3:37
The Nightcoder3-Jun-08 3:37 
Hi!

1. I'm talking about System.Decimal (or just decimal in C#). The details are here:

System.Decimal[^]

2. The link explains this as well. This is a quote of the relevant text:
------
A decimal number is a floating-point value that consists of a sign, a numeric value where each digit in the value ranges from 0 to 9, and a scaling factor that indicates the position of a floating decimal point that separates the integral and fractional parts of the numeric value.

The binary representation of a Decimal value 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-1 is equal to MinValue, and 2^96-1 is equal to MaxValue.

The scaling factor also preserves any trailing zeroes in a Decimal number. Trailing zeroes do not affect the value of a Decimal number in arithmetic or comparison operations. However, trailing zeroes can be revealed by the ToString method if an appropriate format string is applied.
------

So, if the 96-bit integer number is 12345678 and the scaling factor is 5, the number represented is 123.45678 (12345678 / 10^5).

Peter the small turnip

(1) It Has To Work. --RFC 1925[^]

GeneralRe: float calculation issue (decimal is no solution) Pin
George_George3-Jun-08 21:53
George_George3-Jun-08 21:53 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder4-Jun-08 3:04
The Nightcoder4-Jun-08 3:04 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George4-Jun-08 22:22
George_George4-Jun-08 22:22 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder4-Jun-08 23:01
The Nightcoder4-Jun-08 23:01 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George4-Jun-08 23:27
George_George4-Jun-08 23:27 
GeneralRe: float calculation issue (decimal is no solution) Pin
The Nightcoder5-Jun-08 4:01
The Nightcoder5-Jun-08 4:01 
GeneralRe: float calculation issue (decimal is no solution) Pin
George_George5-Jun-08 14:48
George_George5-Jun-08 14:48 
QuestionThreadpool Synchronization causing out of memory error Pin
sumathi pandarinathan26-May-08 0:12
sumathi pandarinathan26-May-08 0:12 
AnswerRe: Threadpool Synchronization causing out of memory error Pin
leppie26-May-08 4:03
leppie26-May-08 4:03 
GeneralRe: Threadpool Synchronization causing out of memory error Pin
sumathi pandarinathan26-May-08 21:09
sumathi pandarinathan26-May-08 21:09 
Questionfolderbrowserdialog Pin
huotari25-May-08 23:57
huotari25-May-08 23:57 
AnswerRe: folderbrowserdialog Pin
Dario Solera26-May-08 0:18
Dario Solera26-May-08 0:18 
AnswerRe: folderbrowserdialog Pin
D i x y26-May-08 0:56
D i x y26-May-08 0:56 
QuestionFix an error 'Page can not be displayed' for file upload control when uploading more than 10mb file size Pin
kishoregani25-May-08 23:30
kishoregani25-May-08 23:30 
AnswerRe: Fix an error 'Page can not be displayed' for file upload control when uploading more than 10mb file size Pin
Dario Solera26-May-08 0:21
Dario Solera26-May-08 0:21 
GeneralRe: Fix an error 'Page can not be displayed' for file upload control when uploading more than 10mb file size Pin
Vasudevan Deepak Kumar26-May-08 19:18
Vasudevan Deepak Kumar26-May-08 19:18 
QuestionHow to get the row/column/data of cells selected in worksheet of Excel using C# Pin
Varad_Rajan25-May-08 23:25
Varad_Rajan25-May-08 23:25 

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.