If you have a float in MSSQLServer, to what do you map this in .NET?
Can you convert it to Double or will you lose numbers?
The float in Microsoft SQL Server is equivalent to a Double in C#. The reason for this is that a floating-point number can only approximate a decimal number, the precision of a floating-point number determines how accurately that number approximates a decimal number.
The FLOAT data type stores double-precision floating-point numbers with up to 17 significant digits. FLOAT corresponds to IEEE 4-byte floating-point, and to the double data type in C. The range of values for the FLOAT data type is the same as the range of the C double data type on your computer.
Convert Float to Int In this example, we will convert a float data type to integer. In the following query, we will declare a variable that data type is float and then we will use the SQL CONVERT function in order to convert float value to integer so for that we will perform data converting operation.
SQLServer float
and C#/VB double
have the same representation. This is the correct mapping. What you don't want to do is map SQL Server float
to C#/VB float
as that may involve a loss of precision. SQL Server real
maps onto C#/VB float
.
T-SQL float and real type definitions can be found at MSDN. C# double definition can be found at MSDN as well, as can the float definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With