If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > float4

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-07, 10:07
DangerM0use DangerM0use is offline
Registered User
 
Join Date: Apr 2007
Posts: 10
float4

I'm just looking through my lecture notes to finish off my assignment and have noticed something in the notes - float4.
I can't find an explanation of what it is/does in them and I don't have my books with me at the moment. Can someone tell me what float4 is and what it does please?
Reply With Quote
  #2 (permalink)  
Old 05-04-07, 10:22
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Guessing from the name, it may be a data type. But there is no FLOAT4 in SQL - neither a data type with that name nor anything else is named that way in the standard.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 05-04-07, 16:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by the_mysql_manual

FLOAT(p) [UNSIGNED] [ZEROFILL]

A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display width and number of decimals are undefined. As of MySQL 3.23, this is a true floating-point value. In earlier MySQL versions, FLOAT(p) always has two decimals. This syntax is provided for ODBC compatibility. Using FLOAT might give you some unexpected problems because all calculations in MySQL are done with double precision.
helps?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 05-05-07, 06:06
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
float-4 versus float-8

I'd think the "4" refers to the storage length in bytes.
As opposed to the other two often used, viz. "float-8" and "float-16". (The latter is e.g. available in the C and C++ programming languages.)
I believe that most relational systems use the term "FLOAT" or "REAL" for float-4, and the term "DOUBLE" for float-8.
Since typically 3 of the 4 bytes are used for the mantissa and 1 for the exponent and the signs, a quick calculation shows that the precision of a float-4 will be about 7 digits (24 bits), while for a float-8 it will be about 14 digits (48 bits).
If I'm not mistaken, the mySQL "p" refers to the number of bits in the precision; hence a FLOAT (or float-4) is most often a FLOAT(24), while a DOUBLE (or float-8) is most often a FLOAT(48).
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/

Last edited by Peter.Vanroose; 05-05-07 at 06:13.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On