Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Decimal described as fixed point?

Tags:

.net

From MSDN:

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.

I thought it was a floating point number with base 10.

like image 909
Dave Hillier Avatar asked Mar 17 '11 14:03

Dave Hillier


People also ask

Why is it called fixed-point?

A fixed point (sometimes shortened to fixpoint, also known as an invariant point) is a value that does not change under a given transformation. Specifically, in mathematics, a fixed point of a function is an element that is mapped to itself by the function.

What is decimal fixed-point representation?

Decimal Fixed-Point RepresentationFixed-point representation has a radix point known as decimal point. Fixed-point numbers having decimal points at the right end of the number are treated as integers because the fixed-point numbers having decimal points at the left end of the number are treated as fractions.

What is the meaning of fixed-point number?

Fixed point numbers are numbers for which there is a fixed location of the point separating integers from fractional numbers. Thus, 15.3 is an example of a denary fixed point number, 1010.1100 an example of a fixed point binary number, and DE. 2A an example of a fixed point hexadecimal number.


2 Answers

Yes, it is a floating point number. That's very old documentation - it was fixed in the .NET 2.0 docs.

(It's unclear whether this was due to me submitting a correction or whether other people had as well. I do remember having to justify my position time and time again, where I thought it was pretty clear - if Decimal was a fixed point type, why did each value include an exponent? I also remember having arguments in C# newsgroups about this, where people were clinging to the documentation as evidence that it really was a fixed point type. Oh well.)

like image 146
Jon Skeet Avatar answered Nov 25 '22 00:11

Jon Skeet


I think it's because you're looking at the .NET 1.1 version of Decimal. The 3.5 version states:

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.

like image 37
vlad Avatar answered Nov 25 '22 00:11

vlad