Author |
Message |
person
|
Posted: Wed Mar 09, 2005 6:00 pm Post subject: Integer overflow in real8 div. |
|
|
how do i solve this problem when it says: "Integer overflow in real8 div."???
thanx in advance |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Wed Mar 09, 2005 6:06 pm Post subject: Re: Integer overflow in real8 div. |
|
|
person wrote: how do i solve this problem when it says: "Integer overflow in real8 div."???
thanx in advance
Can I see the code? It might help to solve it ^^
Usually when I get overflow it is because the number is an int and its too large. |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Wed Mar 09, 2005 6:07 pm Post subject: (No subject) |
|
|
code: |
var num : int
var ans : real := 1
var a := 0
get num
for x : 1 .. num
ans := ans * x
end for
for decreasing x : num .. 1
a := 0
for decreasing y : num .. 1
if (ans / x) / y = (ans / x) div y then % this line overflows
a += 1
end if
end for
if a = num then
ans := ans / x
end if
end for
var num : int
var ans : real := 1
var a := 0
get num
for x : 1 .. num
ans := ans * x
end for
for decreasing x : num .. 1
a := 0
for decreasing y : num .. 1
if (ans / x) / y = (ans / x) div y then
a += 1
end if
end for
if a = num then
ans := ans / x
end if
end for
|
|
|
|
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Wed Mar 09, 2005 6:10 pm Post subject: (No subject) |
|
|
I get an error message...Var previously declared. |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Wed Mar 09, 2005 6:12 pm Post subject: (No subject) |
|
|
D'oh (pressed ctrl+v twice)
anyways
code: |
var num : int
var ans : real := 1
var a := 0
get num
for x : 1 .. num
ans := ans * x
end for
for decreasing x : num .. 1
a := 0
for decreasing y : num .. 1
if (ans / x) / y = (ans / x) div y then
a += 1
end if
end for
if a = num then
ans := ans / x
end if
end for
|
|
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Fri Mar 11, 2005 3:29 pm Post subject: (No subject) |
|
|
does anyone have any ideas to solving this problem?? |
|
|
|
|
![](images/spacer.gif) |
ssr
![](http://siruisite.port5.com/ssr.jpg)
|
Posted: Fri Mar 11, 2005 3:52 pm Post subject: (No subject) |
|
|
srry no idea
but may be the type of input
just an idea
8) |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Fri Mar 11, 2005 4:30 pm Post subject: (No subject) |
|
|
Try changing
code: |
if (ans / x) / y = (ans / x) div y then
|
to
code: |
if (ans / x) / y = (ans / x) / y then
|
. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
person
|
Posted: Fri Mar 11, 2005 4:49 pm Post subject: (No subject) |
|
|
i did that so that i know that its an integer |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Fri Mar 11, 2005 5:12 pm Post subject: (No subject) |
|
|
So, that if statement is trying to determine whether ans / x / y is a whole number?
Lol, sorry, I really should have thought a bit about what I suggested in my above post.
Okay, what about:
code: |
if index (realstr (ans/x/y, 0), ".") > 0 then %if ans/x/y contains no decimals
a += 1
end if
|
btw, your avatar is really large. Please scale it down. |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Fri Mar 11, 2005 6:34 pm Post subject: (No subject) |
|
|
thanx Cervantes!!!
btw: hows this for the size of my avatar? |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Fri Mar 11, 2005 9:51 pm Post subject: (No subject) |
|
|
What are you trying to do btw? ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
Token
![](http://server2.uploadit.org/files/token89-avatar1.jpg)
|
Posted: Fri Mar 11, 2005 10:34 pm Post subject: (No subject) |
|
|
yah person i like this avatar better then the other ones u were experimenting with today |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Sat Mar 12, 2005 11:05 am Post subject: (No subject) |
|
|
Quote: What are you trying to do btw?
ECOO #1 (it works now) |
|
|
|
|
![](images/spacer.gif) |
|