Question: I
have column value of 00000000399 and I need to convert this to a
floating point number like 3.99. How do I convert a number
column to a floating point number?
Answer: Oracle has several ways to convert
a number (or a string!) to a floating pint number. The ideal
of a floating point number is a DISPLAY issue and you convert it at
select time. The Oracle documentation shows these examples for
table column datatypes and displayed values:
Oracle number data types and floating points
(Source: Oracle Corporation Documentation)
Oracle string to number conversion:
Consider a table with a character string, containing a number:
create table
mytab
(numcol varchar2);
insert into mytab values
('12345.67');
In SQL*Plus, Oracle will
automatically convert a string to a floating point number (called
"implicit conversion") or a number data type to a float display using the “column" and "format” clauses:
column numcol format
9999.99
select to_number(numcol) from mytab;
You can also convert a string datatype to a floating point
number using Oracle built-in functions:
select
to_binary_double(numcol) binary_double,
to_binary_float(numcol) binary_float_number,
to_number(numcol) number_datatype
from mytab;
|
|
|
|
Guarantee your Success!
Oracle is the
world's most complex, robust and flexible database, considered
impossible to master without a mentor.
That's why all BC
Oracle trainers are working professionals, experts in Oracle who
share their tips and secrets. |
|
| |
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle 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.
Copyright ? 1996 - 2012
All rights reserved.
Oracle ?
is the registered trademark of Oracle Corporation.
|
|