Link to home
Start Free TrialLog in
Avatar of gram77
gram77Flag for India

asked on

Oracle Number Vs Oracle Float datatype

I have a table whose column is declared as number, without any precesion and scale. Still i can store float values.
so when should one use a float datatype?, and what is the difference in the two datatypes. Is a float dataype just a
alias of number datatype or is it much more?


create table dummy
(col1 number);

select * from dummy;
1
1.1
1.11
1.111
1.1111
1.11111
1.111111
1.11111111111111111111111111111
Avatar of Pratima
Pratima
Flag of India image

Oracle's BINARY_FLOAT stores the data internally using IEEE 754 floating-point representation, like C and many other languages do. When you fetch them from the database, and typically store them in an IEEE 754 data type in the host language, it's able to copy the value without transforming it.

Whereas Oracle's FLOAT data type is a synonym for the ANSI SQL NUMERIC data type, called NUMBER in Oracle. This is an exact numeric, a scaled decimal data type that doesn't have the rounding behavior of IEEE 754. But if you fetch these values from the database and put them into a C or Java float, you can lose precision during this step.
ASKER CERTIFIED SOLUTION
Avatar of gram77
gram77
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gram77

ASKER

number and float are stored internally in same fashion.
create table t3 (
x3 number
,f3 float
);

insert into t3 (x3, f3) values (1,1);

commit;

select dump(x3) x3, dump(f3) f3 from t3;

drop table t3;
Avatar of gram77

ASKER

best solution