Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: float data type
A copy of this was sent to tedchyn_at_yahoo.com
(if that email address didn't require changing)
On Fri, 03 Sep 1999 15:55:43 GMT, you wrote:
>Thomas,
>1. what about internal storage how many bytes for number and float if no
> number specified -e.g. column_1 float, column_2 number ?
all numbers of any type (int, float, number(x,y)) are all stored in the same manner -- in an Oracle number. Think of float(6) as being an "edit", very similar to saying "number(2)" but it will auto round the number for you to fit.
>2. Is there any shortcoming in defining a column with float ?
I cannot think of any reason for wanting to use a column of type float -- it just doesn't seem as natural as using number(n,m).
>3. why select display 120000 instead of 123456 for float(6) in your
>example ?
because a float(6) can handle only 2 digits of precision so you lose digits. Its sort of like the c code:
$ cat test.c
void main()
{
double x;
float y;
x = 1234567.89123; y = x; printf( "x = %lf, y = %f\n", x, y ); x = y; printf( "x = %lf, y = %f\n", x, y );}
$ ./test
x = 1234567.891230, y = 1234567.875000
x = 1234567.875000, y = 1234567.875000
moving things about in differing precisions looses digits -- thats what happens below with a float(6) (a 6 bit floating point number -- can only hold 2 digits)
>Thanks
>Ted Chyn(tedchyn_at_yahoo.com)
>
>
>In article <t8XPN68EtajHNwjVVEiclp8wBy9Q_at_4ax.com>,
> tkyte_at_us.oracle.com wrote:
>> A copy of this was sent to tedchyn_at_yahoo.com
>> (if that email address didn't require changing)
>> On Thu, 02 Sep 1999 20:41:26 GMT, you wrote:
>>
>> >Sir, Is there differences between data type number and data type
>> >float in defining a table ? number is well document in oracle manual
>and
>> >float is not. Any comments is appreciated.
>> >
>>
>> big difference.
>>
>> tkyte_at_8.0> create table t ( x number(6), y float(6) );
>>
>> Table created.
>>
>> tkyte_at_8.0>
>> tkyte_at_8.0> insert into t values ( 123456, 123456 );
>>
>> 1 row created.
>>
>> tkyte_at_8.0> select * from t;
>>
>> X Y
>> ---------- ----------
>> 123456 120000
>>
>> a float 6 can hold 2 digits of precision.
>> a float 16 is like a C float -- it can hold about 6 digits of
>precision.
>>
>> >Thanks Ted Chyn(tedchyn_at_yahoo.com)
>> >
>> >
>> >Sent via Deja.com http://www.deja.com/
>> >Share what you know. Learn what you don't.
>>
>> --
>> See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to
>Oracle8i'...
>> Current article is "Part I of V, Autonomous Transactions" updated
>June 21'st
>>
>> Thomas Kyte tkyte_at_us.oracle.com
>> Oracle Service Industries Reston, VA USA
>>
>> Opinions are mine and do not necessarily reflect those of Oracle
>Corporation
>>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri Sep 03 1999 - 11:36:58 CDT
![]() |
![]() |