+ 11
Why in int, numbers grander than 2147483647 write as a minus?
I made an application, my first app (!) and, I can see, when big numbers(bigger than 2147483647) should come, as an integer, he becomes to minus. I can understand that int can't contain numbers bigger than the The divine number, but why they become to a minus number? The computer does not just throw out numbers and add a minis. So why is there a minus? What does it do?
14 Respostas
+ 3
Max Ok... At end we saw same thing... Anyway Itiel Dan go here for futhermore info https://en.m.wikipedia.org/wiki/Signed_number_representations
+ 9
Max OK
thank you very much. and good nite, for now it's clear enough, I should learn more about binary numbers, good nite.
+ 6
Max if i understood you, if my number is 214748364755
so it will -4748364755?
i think i didn't understood U. can u explain again? and maybe give some examples?
+ 4
Max In real world its used complement two representation not bit sign because latter has some problems (duplication of zero representation and overall lack compatibility to make atomic operation at cpu level)... In a n-bit int size, you can think about he most left bit like value
-(2^(n-1)) then his value:
in 2 bit int size is -(2^1)= -2
in 3 bit int size is -(2^2)= -4
in 4 bit int size is -(2^3)= -8
in 32 bit size is -(2^31)= -2147483648
Hence in 4 bits 1000 its equal to -8 in a system using complement two representation (most common representation)
+ 3
Max I have edited because i writed wrong (one but i intented two)... In your comment you have not used complement but sign bit representation
+ 2
because an int uses 4 bytes to store a number and 2^32 = something and half of that equals your number +/- 1(half because we need to encode if the number is positive or negative)
use a long if you want to store bigger numbers( i think there also is a BigInt implementation for java). they get negative because of the way twos complement works and because if you perform an operation and the result is bigger than the magic value it performs the addition and just "forgets" the aditional digits that would be created(twos complement: if the left bit is 1 number is negative, to get value:
not the number, -result of the not -1 is your number). so if you continue adding for example at some point it rolls over to left bit 1
+ 2
for example with 4 bits(i donât want to write more)
assume you have 0111 (which is 7) if you add 1 you get 1000 (8, but first bit actually indicates the sign)so its negative.
not 1000 is 0111 so your number is -111 - 1 or in decimal -8
+ 2
KrOW directly copied from wikipedia:
"However, unlike two's complement, these numbers have not seen widespread use because of issues such as the offset of â1, that negating zero results in a distinct negative zero bit pattern, less simplicity with arithmetic borrowing, etc."
"Two's complement is the most common method of representing signed integers on computers."
"Compared to other systems for representing signed numbers (e.g., ones' complement), two's-complement has the advantage that the fundamental arithmetic operations of addition, subtraction, and multiplication are identical to those for unsigned binary numbers"
+ 2
Max Yes, it say that i have writed but more clear
+ 2
KrOW no, it says that in the real world twos complement is used (like i explained in my comment) but you said that ones complement is used
+ 2
KrOW i just noticed that i forgot to subtract one, will edit now
0
abate tesfaw Remove your unrelated comment
- 3
because bitwise operation
- 3
"""
This is my First Ever Code in Python.
Thanks to this SoloLearn Community and it's very well-behaved, polite members.
The technique used to write the alphacodes is "Run-Length Encoding Compression Technique"
To run the Code you simply have to Enter a String (or your Sweet Name)
If you found any bug or any Problem in executing this Code, please let me know about that in the Comment Section below!
I've aligned the text vertically, because horizontal alignment is not possible for more than 4 charcters on mobile app.
"""
print("""
It's very good to See you Here!
I Hope You'll Like This...
Coded by: CuriosBasant
""")
C='CdC' #frequently used string
alpha = {
'A': ['aH','J']+[C]*2+['J']*2+[C]*2,
'B': ['I','J',C,'I'],
'C': ['aH','J',C,'Cg'],
'D': ['G','I']+[C]*2,
'E': ['I']*2+['C','I'],
'F': ['I']*2+['C']+['H']*2+['C']*3,
'G': ['aH','J','C']+['CbE']*2+[C,'J','aH'],
'H': [C]*3+['J'],
'I': ['H']*2+['bD']*2,
'J': ['fD']*5+['CcD','J','aH'],
'K': ['CcD','CbD','CaD