Home » RDBMS Server » Server Administration » Storing negative numbers
Storing negative numbers [message #374668] Sat, 23 June 2001 15:06 Go to next message
Joyce
Messages: 13
Registered: March 2000
Junior Member
Hello! I have a basic question.
How does one store negative numbers in oracle? I'm
using Oracle 8.1.5 and I'm trying to store latitude
and longitude values. I've tried various precisions
and scale. I've also tried changing the type to 'NUMBER'. But whenever I try to store a number such as
-122.397804, oracle insists on rounding it to
-122.3978. I also noticed that with the type NUMBER,
when I try to store a positive number such as
1.000002 or the like, it'll round it to 1. I thought
NUMBER was supposed to store the number as is.

Could somebody please tell me what's going on?
Thanks!

Joyce
Re: Storing negative numbers [message #374688 is a reply to message #374668] Sun, 24 June 2001 23:56 Go to previous messageGo to next message
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
I wonder if it gives really a problem with storing negatives. Oracle stores negative numbers as they are. I too tried here with Oracle8.1.5 it stores perfectly as given, the negatives. No problem at all. Try with INTEGER type. If still there is a problem, try with either CONVERT or CAST functions. But I am very sure that oracle8.1.5 should and must store negatives as they are (even I tried too).
Re: Storing negative numbers [message #374689 is a reply to message #374668] Mon, 25 June 2001 00:01 Go to previous messageGo to next message
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
I wonder if it gives really a problem with storing negatives. Oracle stores negative numbers as they are. I too tried here with Oracle8.1.5 it stores perfectly as given, the negatives. No problem at all. Try with INTEGER type. If still there is a problem, try with either CONVERT or CAST functions. But I am very sure that oracle8.1.5 should and must store negatives as they are (even I tried too).
Re: Storing negative numbers [message #374690 is a reply to message #374668] Mon, 25 June 2001 00:11 Go to previous messageGo to next message
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
I wonder if it gives really a problem with storing negatives. Oracle stores negative numbers as they are. I too tried here with Oracle8.1.5 it stores perfectly as given, the negatives. No problem at all. Try with INTEGER type. If still there is a problem, try with either CONVERT or CAST functions. But I am very sure that oracle8.1.5 should and must store negatives as they are (even I tried too).
Re: Storing negative numbers [message #374691 is a reply to message #374668] Mon, 25 June 2001 01:39 Go to previous message
Sarada
Messages: 27
Registered: April 2001
Junior Member
Hi Joyce,

I found out something interesting. I guess you were trying the above in SQL*PLUS. I tried exactly the same as what you had asked in SQL*PLUS.

Normally the environment variable "numwidth" in SQLPLUS would be set to 9. This is the reason for the negative number getting rounded off. Try increasing it and see. It works. The reason is it needs 1 more place extra to show the "-"ive sign hence the rounding off happens when compared to "+"ive number.

GSM521D5>desc xx
Name Null? Type
------------------------------- -------- ----
DD DATE
FF DATE
VALUE NUMBER(38,10)

GSM521D5>insert into xx(value) values (-122.397804);

1 row created.

GSM521D5>c/-122.397804/1.000002
1* insert into xx(value) values (1.000002)
GSM521D5>/

1 row created.

GSM521D5>select value from xx;

VALUE
---------
-122.3978
1.000002

GSM521D5>set numwidth 20
GSM521D5>select value from xx;

VALUE
--------------------
-122.397804
1.000002

HTH
Orashark
Previous Topic: what exactly is a nested table ?
Next Topic: Any alternate for Record group in forms-V4.5????-Earnest Request.
Goto Forum:
  


Current Time: Sat Jul 06 19:00:18 CDT 2024