Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET - Why is there no fixed point numeric data type in C#?

It seems like there would be a ton of uses for a fixed point data type. Why is there not one in .NET?

Note: I understand we can create our own classes/structs to suit our fixed point purposes and needs. That's not my question. I want to know WHY MS decided not to include a fixed point numeric data type.

like image 399
richard Avatar asked Feb 21 '11 18:02

richard


People also ask

Which data type in C# can store numeric values with decimal places?

Decimal. The decimal data type can store fractional numbers from ±1.0 x 10-28 to ±7.9228 x 1028. It occupies 16 bytes in the memory. The decimal is a keyword alias of the Decimal struct in .

How many decimal places can float hold C#?

C# decimal precision The decimal type is a 128-bit floating point data type; it can have up to 28-29 significant digits.

What is a fixed-point data type?

A fixed-point data type is characterized by the word length in bits, the position of the binary point, and whether it is signed or unsigned. The position of the binary point is the means by which fixed-point values are scaled and interpreted.


1 Answers

You're looking for the little-known System.Data.SqlTypes.SqlDecimal class.

like image 55
SLaks Avatar answered Sep 17 '22 23:09

SLaks