I’m attempting to use a double to represent a bit of a dual-value type in a database that must sometimes accept two values, and sometimes accept only one (int).
So the field is a float in the database, and in my C# code, it is a double (since mapping it via EF makes it a double for some reason… )
So basically what I want to do .. let’s say 2.5 is the value. I want to separate that out into 2, and 5. Is there any implicit way to go about this?
Like this:
If you want
fractionalPartto be anint, you can multiply it by 10n, wherenis the number of digits you want, and cast toint.However, beware of precision loss.
However, this is extremely poor design; you should probably make two fields.
SQL Server’s
floattype is an 8-byte floating-point value, equivalent to C#’sdouble.