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

Username:   Password: 
 RegisterRegister   
 glitch in turing?!?! O.o 405 =/= 405
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chopperdudes




PostPosted: Tue Feb 17, 2009 6:19 pm   Post subject: glitch in turing?!?! O.o 405 =/= 405

well if you could just copy and paste the following simple code into turing you'd know what i'm talking about... and it's not about data type conflict as i've shown in the last line...


Turing:

var a := 66430125

put "the number is ", a
put ""
put a, " to the third root is ", a ** (1 / 3)
put ""
put "round ", a, " to the third root is ", round (a ** (1 / 3))
put ""
put "it is ", a ** (1 / 3) = round (a ** (1 / 3)), " that ", a ** (1 / 3), " = ", round (a ** (1 / 3))
put ""
put "it is ", 1.0000 = 1, " that 1.0000 = ", 1



any1 know what's going on?!
Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Tue Feb 17, 2009 9:53 pm   Post subject: RE:glitch in turing?!?! O.o 405 =/= 405

This is a wild guess, but I think when you round in Turing, some information about the real number is lost because it's changing types. It's like if in Java you have two strings that have "Hello" in it. But they aren't equal because their locations in memory are pointers to another location where the strings are located. The pointers are different, so then they are not equal. I think if you make string1 = string2 though, they are the same because they have the same pointer to the exact same place in memory. I don't know if I'm explaining it right...actually I don't even know if I'm right.
DanielG




PostPosted: Tue Feb 17, 2009 10:21 pm   Post subject: RE:glitch in turing?!?! O.o 405 =/= 405

I believe it's simply a rounding error, when turing (and most programming languages) calculate sqrt, it's not perfect, so sqrt(25) might be 5.0000001 or 4.999999, which although appearing as 5 (since it only prints so many digits), it doesn't consider it to be
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 1  [ 3 Posts ]
Jump to:   


Style:  
Search: