0
Beyond limit ?
i know the longest data type is unsigned long long, but what happen when we assign number beyond the limit? shouldn't it output error? but it output strange number ? where is that number come from? see my code below : https://code.sololearn.com/cNyRlDBZS9ax/?ref=app
9 Respuestas
+ 2
It would have different numbers for different compiler, especially compiler that run on different machine 32/64 bits.
+ 1
it doesn't error because it isn't technically wrong.
youve tried to assign a number that is too big and the program just returns what the pointer is pointing to.
the same way changing a double into an int just removes everything after the decimal without an error
+ 1
thanks @Daemo, so it was not random number?
does it output different number in different compiler? i mean the "too big number".
+ 1
You have reached the edge of the Universe.
+ 1
@setiawan I have not compared between different compilers but I'm sure someone must have done this before
+ 1
@Calvin
Do i just get the world record title as "the first human who reach the edge of universe and still don't understand where the strange number come from"
and then Dr. Strange will answer : " it come the part of universe which exist before the time"
+ 1
@Calvin
oh, i see. thanks, i'll try it tonight.
+ 1
@Setiawan,
No, it's not a world record but an universe record.
From Albert Einstein theory, General Theory of Relativity, it said the Universe is like a Computer underlines with numbers and information.
I think the God, must be the universe top coder.
+ 1
Depends on your compiler. If your compiler does nothing about it or doesnt give you any errors when you try to compile, the variable will just be set to the largest negative value, or 0 if the variable is unsigned. It works like a speedometer.