Call now: (800) 766-1884  



 Home


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA



 Articles
 Services
 SQL Server Scripts
 Scripts Menu



 

 

 

   
  SQL Server Tips by Gama and Naughter

Real and float

Real is a floating point numeric value with valid values 3.40E + 38 through -1.18E - 38, 0 and 1.18E - 38 through 3.40E + 38.
Float has valid values - 1.79E + 308 through -2.23E - 308, 0 and 2.23E -308 through 1.79E + 308.
The following example shows how a real value is stored using 32 bit IEEE single-precision:

DECLARE @r real
SET @r=12345.67
SELECT @r, DATALENGTH(@r)
SELECT CAST(@r as binary(4))

12345.67 4
0x4640E6AE

Converting 4640E6AE to binary:

0 10001100 10000001110011010101110
S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
0 1 8 9 31


S is the sign of the mantissa, E the exponent and F is the decimal part of the mantissa.

S=0, E=140, F=81CD5C => 1.F=1.81CD5C=1.50703979

Using the IEEE formula:

V=(-1)^S*2^(E-127)*(1.F)=(-1)^0*2^(140-127)*(1.50703979)=1*8192*1.50703979=12345.66995968=12345.67


The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter

 http://www.rampant-books.com/book_2005_2_sql_server_external_procedures.htm  

 

Burleson Consulting Remote DB Administration


 

 


 

 

 

 

 
Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.
 


Burleson Consulting
SQL Server database support

 

Copyright 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter