Computer Science Canada weird effect |
Author: | DanShadow [ Sat Dec 13, 2003 8:49 pm ] | ||||
Post subject: | weird effect | ||||
I got bored, start messing with lines, created some stairway thing.. ![]()
or maybe this odd thing
|
Author: | DanShadow [ Sat Dec 13, 2003 8:55 pm ] | ||
Post subject: | |||
hmm...i think i found a glitch in turing
Leave that running for a mniute, and watch it. See how in the code, the "y" axis is ONLY supposed to decrease? Well then how does it end up higher than the original "y" valu e of 200? *spooky* ![]() |
Author: | Dan [ Tue Dec 16, 2003 12:47 pm ] |
Post subject: | |
same thing will happen in c/c++ but it will take alot longer. that is what most progaming languges do when you hit max number (or min), they go back to some set number. it is praty so the hole comp dose not crash when you get a value over the x big. |
Author: | DanShadow [ Wed Dec 17, 2003 12:00 pm ] |
Post subject: | |
Oh I see...except seemingly when in C++, when you reach a "too" large integer, it crashes the program, heh. |
Author: | Tony [ Wed Dec 17, 2003 1:17 pm ] |
Post subject: | |
This all has to do with the way signed numbers work. Anyone knows how to represent negative numbers in binary? ![]() Binary numbers have a leading bit. 0 for possitive, 1 for negative. When you overflow the number - say you have an 8 bit integer. It is actually 9 bits long. So when you have 256+1, in binary its 011111111 +1 100000000 now since the integer is only 8 bits long, this number represents negative 0. As you add more, you keep on going backwards. 100000001 is -1 and so on. The reason for C++ to take "longer" is because integers are "longer" - meaning more bits to fill before overflow. |
Author: | kalin [ Tue Jan 20, 2004 3:37 pm ] |
Post subject: | |
Both of those things are really really really really *cough cough* wierd |