Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you assign a variable with infinite value,urgent

Status
Not open for further replies.

mkey

Programmer
Oct 3, 2001
288
CA
Hi All,
I need to assign a variable with infinite value in Pl/SQL.
Any ideas?

Thanks!
 
How do you define INFINITE? As far as I know, there is no discrete value for INFINITE, so you are going to have to create your own definition and then use it.
If you are using a number datatype, every system will have a limit which is dependent upon how many bits it can handle at a time, so true INFINITY is impossible.

What is it you are really trying to do? Perhaps somebody can provide you with a workable solution.
 
The magnitude limit of PLS_INTEGER and BINARY_INTEGER in PL/SQL is -2147483647 .. 2147483647 "Helping others to help themselves..."
=================================
Thomas V. Flaherty Jr.
Birch Hill Technology Group, Inc.
 
You can also declare numbers that are whole numbers (INTEGER). An Oracle integer may have up to 38 digits.


"Helping others to help themselves..."
=================================
Thomas V. Flaherty Jr.
Birch Hill Technology Group, Inc.
 
Right, you need to define exactly what you are trying to do. Just assigning max values to a column won't actually make the value behave like infinity. Some things work, but others don't. For example

infinity > number
2147483647 > number
This probably works, because you most likely won't need to store 2147483647 as a real value.

On the other hand

infinity - number = infinity
2147483647 - number = number
That doesn't work at all, so you have to be careful not to perform arithmetic on "infinite" values.
 
And just to round out the pantheon of numbers,
floating point goes from 1E-130 to 10E125 (which, while not really close to infinity, will get you a long way towards it!).
 
I don't know, Carp. The largest known prime number is around 10E4000000. I would be a lot more impressed if Oracle provided a datatype large enough to store it.
 
Me too. And I'd be REALLY impressed if they could do infinity!! However, even Oracle's documentation indicates that they are limited by your hardware, so your results may vary.
 
Hi,
Even more impressive would be to handle imaginary and transfinite numbers as well....

[profile]
ps ( I have always loved the concept of an imaginary number)

 
HI all,
I am doing bunch of calculation within my procedure.
Now the values can be all over the place.
Example

lat = 97.12456
long = 29.12345
va1 = 2.000245654

infinite_val := 1000000000;

What is a good datatype I could use for all these possibilities. Right now I'm using float datatype.But the outcome is not what I expect. Any thoughts will help! I need to perform arithmatic funtion on a infinite. How can I do this?
 
Please take the time to explain why you need to perform arithmetic on infinity. Infinity isn't a number, so operations defined on real numbers aren't defined on a set that includes infinity.

It's hard to avoid the impression that you are modeling your work incorrectly. I don't see the justification of inventing a whole new arithmetic that allows operations on infinity. Even less do I see how to do this in a database implementation where you are limited by the physical limitations of storage.
 
Perhaps NULL would come close:

NULL + 50 = NULL
NULL * 50 = NULL
etc.

Of course, adding n+1 an infinite number of times won't get you to NULL. But then again, I don't think it would work for INFINITY either.

If you are doing arithmetic, then some kind of number is a good choice. If integers won't work, then by all means a floating point number is the way to go.

For about the fourth time in this thread, what -exactly - are you trying to do?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top