Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Integer overflow problem with turing's trig functions.
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CodeMonkey2000




PostPosted: Fri Aug 24, 2007 7:00 pm   Post subject: Integer overflow problem with turing's trig functions.

When I run this I keep getting an integer overflow error.

Turing:

fcn tand (angle : real) : real
    result sind (angle) / cosd (angle)
end tand
put round (tand (90))


How do I get around this? The number you get in that function isn't even that big (in fact it's quite small), why is it giving me this error? Oh and I need to deal with integers. Using just real variables won't help me.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Fri Aug 24, 2007 7:04 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

tand(90) = infinity =\ how could it be small?

Actually why isin't it complaining of div by zero?
CodeMonkey2000




PostPosted: Fri Aug 24, 2007 7:09 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

Oh right use radian Razz
Clayton




PostPosted: Fri Aug 24, 2007 7:10 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

And just to clarify:

tand 90 = sind 90 / cosd 90
tand 90 = 1 / 0

That's why it doesn't work Confused
rizzix




PostPosted: Fri Aug 24, 2007 7:12 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

Radians or degrees, either one would result in Infinity.

My concern is why isin't cosd(90) = 0???
Clayton




PostPosted: Fri Aug 24, 2007 7:58 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

I'm not sure Confused Turing represents cosd (90) as 1.22 x 10^-16, yet sind (90) = 1
CodeMonkey2000




PostPosted: Fri Aug 24, 2007 10:03 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

Another strange thing is that tand(90) won't give you an error. Only when you try to convert it in to an integer through round,ceil or floor will you get an error. So it realizes its mistake when you attempt to convert it.
Clayton




PostPosted: Fri Aug 24, 2007 10:09 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

Uh... tand(90) definitely gives an error in the way of "Quit #51"
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Fri Aug 24, 2007 10:13 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

That's strange, on my computer it gave me:

8.16423 x10^18
rizzix




PostPosted: Fri Aug 24, 2007 10:31 pm   Post subject: RE:Integer overflow problem with turing\'s trig functions.

You're using a different version of Turing. I'm guess ing ver < 4.1
Prince Pwn




PostPosted: Sat Aug 25, 2007 1:45 am   Post subject: RE:Integer overflow problem with turing\'s trig functions.

How do u ppls know how to use tangent and stuff. I dont understand any of that.
Nick




PostPosted: Sat Aug 25, 2007 7:52 am   Post subject: RE:Integer overflow problem with turing\'s trig functions.

you learn in math... i think gr 11 advanced or gr 12
Clayton




PostPosted: Sat Aug 25, 2007 8:59 am   Post subject: RE:Integer overflow problem with turing\'s trig functions.

@momop, your avatar is too large, please resize it to something smaller.

@rizzix, he's probably the one using 4.1, I'm using 4.0.5

@Prince Pwn, Grade 10 math you start to learn trig... at least... you should have Confused
CodeMonkey2000




PostPosted: Sat Aug 25, 2007 9:32 am   Post subject: RE:Integer overflow problem with turing\'s trig functions.

I have turing 4.0.3.
CodeMonkey2000




PostPosted: Sat Aug 25, 2007 9:37 am   Post subject: RE:Integer overflow problem with turing\'s trig functions.

But that's good enough. Trig really isn't that hard. It's not hard to go further than what they teach you either. I'm going into grade 11.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: