Monday, August 6, 2018

FLOAT vs. REAL in T-SQL

The single number specified when making a FLOAT type column in T-SQL is the number of bits to allocate for space. 1-24 creates a 7 digit precision and 25-53 digits specifies a 15 digit precision. A REAL type column is equal to a FLOAT(24) type column. See this and this for more. An example:

CREATE TABLE Cat
(
   CatId INT NOT NULL IDENTITY,
   Name VARCHAR(50),
   LivesLeft FLOAT(24),
   LivesToBeginWith REAL,
   CONSTRAINT PK_Cat PRIMARY KEY (CatId)
);

 
 

The number for FLOAT is as scary as the shadow of this seemingly pretty girl I took a photo of at the Hahn/Cock sculpture of Katharina Fritsch at the Minneapolis Sculpture Garden yesterday. How obtuse and confusing.

No comments:

Post a Comment