Home » SQL & PL/SQL » SQL & PL/SQL » Float (10.2.0.3, Windows 2003)
Float [message #404348] Thu, 21 May 2009 08:14 Go to next message
sant_new
Messages: 165
Registered: June 2008
Senior Member
Hi all,

Is it necessary to give precision and scale for float datatype? Our data will need to have four places to right of decimal, it needs to be float. Do I have to create with float(precision) or just float?

Thanks much
Re: Float [message #404350 is a reply to message #404348] Thu, 21 May 2009 08:17 Go to previous messageGo to next message
joy_division
Messages: 4727
Registered: February 2005
Location: East Coast USA
Senior Member
Try it and see what happens.
Re: Float [message #404352 is a reply to message #404348] Thu, 21 May 2009 08:24 Go to previous messageGo to next message
Michel Cadot
Messages: 64731
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL Reference
Chapter 2 Basic Elements of Oracle SQL
Section Datatypes
Subsection Oracle Built-in Datatypes
Paragraph Floating-Point Numbers

I recommend you to use NUMBER and not FLOAT dadatype unless your DDL must be ANSI.

Regards
Michel
Re: Float [message #404358 is a reply to message #404348] Thu, 21 May 2009 08:42 Go to previous messageGo to next message
sant_new
Messages: 165
Registered: June 2008
Senior Member
I tried a few test cases:

create table test ( a float)

insert into test values (-1.111543453451)

select * from test

----------
-1.1115435


create table test ( a float(5))

insert into test values (-1.111543453451)

select * from test

----------
      -1.1

create table test ( a float(10))

insert into test values (-1.111543453451)

select * from test
----------
    -1.112

create table test ( a float(14))

insert into test values (-1.111543453451)

select * from test

----------
   -1.1115



So, if we want only 4 places after decimal do we have to go with float(14)? I'm not sure how it is calculated..

Thanks
Re: Float [message #404362 is a reply to message #404358] Thu, 21 May 2009 08:47 Go to previous message
Michel Cadot
Messages: 64731
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
I'm not sure how it is calculated..

It is in the documentation I pointed you and this is why I recommend to NOT use it.

Regards
Michel
Previous Topic: Strange PLS-00302 behavoir
Next Topic: Clob, PLSQL table type, Collections
Goto Forum:
  


Current Time: Sun Apr 30 23:56:13 CDT 2017

Total time taken to generate the page: 0.12006 seconds