I have a value, EdgeChangeThreshold which is the
minimum change in an edge (yesterday vs today) for a stock details to be displayed on the page

This value will be entered by the users. The calculated formula for the difference in edge is a basis point (abs(previous edge )- abs(current edge))/previous edge (display format 0.0000%) that will be displayed .

In order to validate the value entered based on which I can return the security details, should I use decimal or single or double(System.Struct)? What is the difference?

The System.Decimal type is a kind of hybrid between an integer and a floating-point number. It is a 128-bit (16-byte) data structure that can
exactly represent values ranging from -79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335, with up to 29 significant digits. The C# name for this type is
decimal. In Visual Basic it's Decimal.

The Decimal type is a structure that consists of a 1-bit sign, a 96-bit integer, and a scaling factor that specifies where to put the decimal point. The scaling factor is a number from 0 to 28, representing the number 10 raised to that power, which
is used to divide the 96-bit integer. So, if the integer number is 12 and the scaling factor is 1, then the value represented is 12 divided by 10^{1}, or 1.2.

The beauty of this type is that it can exactly represent decimal values—something that's especially important when working with currency values. Whereas floating-point numbers are approximations (albeit very close approximations), decimal values are exact.
For example, if you use a floating-point type to add and subtract currency values, eventually you'll end up with a number that has more than just two decimal places. You might end up with 349.999997, for example.

If you use a Decimal type to add currency values, you'll always end up with two decimal places.

Darrell Norton, MVP
Darrell Norton's Blog Please click "Mark as Answer" if this helped you.

I would use Decimal because Basis point is just fancy way for decimal points in different places, ten basis points movement is the stock moved ten cents in either direction. So 100 basis points in layman language is 100 cents which is one dollar, a few currencies
like yen minor difference. In SQL Server if you are doing calculations you may need Float because eighty percent of the quantitative functions like LOG are in Float but when calculating money it is good practice to use either Numeric or Decimal in your creat
table statement so you can control precision and scale.

BTW the NYSE did not change to basis points until everybody was required to change. Hope this helps.

None

0 Points

36 Posts

## Single vs Double - precision floating point number

Mar 02, 2006 11:58 AM|dotnetnew123|LINK

Hello,

I have a value, EdgeChangeThreshold which is the minimum change in an edge (yesterday vs today) for a stock details to be displayed on the page

This value will be entered by the users. The calculated formula for the difference in edge is a basis point (abs(previous edge )- abs(current edge))/previous edge (display format 0.0000%) that will be displayed .

In order to validate the value entered based on which I can return the security details, should I use decimal or single or double(System.Struct)? What is the difference?

Thanks in advance!!!

dotnetnew123

All-Star

43204 Points

10243 Posts

MVP

## Re: Single vs Double - precision floating point number

Mar 02, 2006 02:15 PM|DarrellNorton|LINK

## Fixed-point Type

The

System.Decimaltype is a kind of hybrid between an integer and a floating-point number. It is a 128-bit (16-byte) data structure that canexactlyrepresent values ranging from -79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335, with up to 29 significant digits. The C# name for this type isdecimal. In Visual Basic it'sDecimal.The

Decimaltype is a structure that consists of a 1-bit sign, a 96-bit integer, and a scaling factor that specifies where to put the decimal point. The scaling factor is a number from 0 to 28, representing the number 10 raised to that power, which is used to divide the 96-bit integer. So, if the integer number is 12 and the scaling factor is 1, then the value represented is 12 divided by 10^{1}, or 1.2.The beauty of this type is that it can exactly represent decimal values—something that's especially important when working with currency values. Whereas floating-point numbers are approximations (albeit very close approximations), decimal values are exact. For example, if you use a floating-point type to add and subtract currency values, eventually you'll end up with a number that has more than just two decimal places. You might end up with 349.999997, for example.

If you use a

Decimaltype to add currency values, you'llalwaysend up with two decimal places.Darrell Norton's Blog

Please click "Mark as Answer" if this helped you.Contributor

4150 Points

5249 Posts

## Re: Single vs Double - precision floating point number

Mar 06, 2006 10:43 AM|Caddre|LINK

I would use Decimal because Basis point is just fancy way for decimal points in different places, ten basis points movement is the stock moved ten cents in either direction. So 100 basis points in layman language is 100 cents which is one dollar, a few currencies like yen minor difference. In SQL Server if you are doing calculations you may need Float because eighty percent of the quantitative functions like LOG are in Float but when calculating money it is good practice to use either Numeric or Decimal in your creat table statement so you can control precision and scale.

BTW the NYSE did not change to basis points until everybody was required to change. Hope this helps.