c# - Float type field in Model while automatically created in database as real type? -
iam using mvc4 .i have model .in model created field called "allfuels" of data type float. when table automatically created in database data type of field "allfuels" real.iam using model first method .can know reason why happening?
public float allfuels { get; set; }
but field in table created real datatype.
... why happening?
well, that's easy - because mapping programmed ef.
does matter?
look @ following:
- sql server bol: float , real (transact-sql):
- -3.40e + 38 -1.18e - 38, 0 , 1.18e - 38 3.40e + 38
- 4 bytes storage
- the iso synonym real float(24).
- 7 digits precision
- float (c# reference)
- -3.4 × 1038 +3.4 × 1038
- 7 digits precision
- 32-bit storage (4 bytes)
so "approximate range" † same both, storage amount: both 32-bit floating binary point types. annoying thing .net float not mentioned in bol reference data type conversion, makes hard ‡.
in addition, edm.float
listed in edm data types (msdn: conceptual model types (csdl)) floating point 7-digit precision, matches float in .net , real in sql server (csdl xml language describes entites, relationships etc. , used ef).
so should do?
what microsoft floating point in ado.net? if read: msdn - data type mappings in ado.net (floating-point numbers) "test". that, , if precision not enough you, .net type needs double
instead, should become higher precision type in sql server (it translate float(53)
, believe)
† i couldn't find ieee reference, point @ wikipedia definition of "approximate range".
‡ edit guru lasse v. karlsen totally right ask me qualify statement: single
equivalent float
, badly expressed point have know single
rather float
able find information in reference.
Comments
Post a Comment