PDA

View Full Version : 32768


VetLegion-
26-07-2007, 18:46:19
You know you've done too much programming when...

...you notice that "Word Association I - Forum Addiction" thread has reached 32332 replies and you think to yourself: boy, I hope they used an unsigned or a long!

:smoke:

Resource Consumer
26-07-2007, 18:52:22
translation please?

VetLegion-
26-07-2007, 19:09:25
Basically, if a variable is of type that has two bytes (usually int or word) and it is signed it can only store values up to 32768. When you try to add 1 to that - boom!

The consequences can be dire.

VetLegion-
26-07-2007, 19:19:08
http://en.wikipedia.org/wiki/Integer_overflow

Vincent
26-07-2007, 20:33:18
Fuckin nerds

Drekkus
26-07-2007, 21:09:39
Did you know that integer is integrity in dutch. Or not really integrity, more like integritous or something

Vincent
26-07-2007, 21:16:28
I'm real integer

Koshko
26-07-2007, 21:47:03
Originally posted by Vincent
Fuckin nerds

This thread transcends beyond mere nerdishness.

VetLegion-
26-07-2007, 21:53:34
Thank you, thank you :)

Lazarus and the Gimp
26-07-2007, 22:00:23
Originally posted by VetLegion-
Basically, if a variable is of type that has two bytes (usually int or word) and it is signed it can only store values up to 32768.

What? What sort of jibber-jabber is this?

KrazyHorse
27-07-2007, 00:10:12
When programming you generally have to tell the computer what type of variable things are.

One type of variable is generally an INT (integer). When you tell the computer "the following is an integer" it saves 2 bytes = 16 bits for it in memory. A bit is either a 1 or a 0. Integers are generally allowed to be either +ve or -ve, so one bit is reserved for the sign. The other 15 bits make up the integer. With 15 bits you can make all the numbers from 1 to 2^15 = 32768

If they represent thread length with a regular signed integer then once a thread goes past 32768 posts bad things will happen.

Now, lets say that instead of 16 bits, ints were usually only 4 bits. The first bit is for sign (1 means +ve 0 means -ve), so the coding is as follows:

0000 = -7
0001 = -6
0010 = -5
0011 = -4
0100 = -3
0101 = -2
0110 = -1
0111 = 0
1000 = 1
1001 = 2
1010 = 3
1011 = 4
1100 = 5
1101 = 6
1110 = 7
1111 = 8

More than likely they assigned a long or bigger to the thread size, so we can comfortably get 2 million or more posts in before causing crashes. The long type has 4 bytes, so if signed it goes up to 2^31 = 2097152

Vincent
27-07-2007, 05:31:52
what's that in packed (comp-3)?

Funko
27-07-2007, 08:01:42
I reckon they just stored it as text.

Resource Consumer
27-07-2007, 09:21:45
Originally posted by KrazyHorse


..... so we can comfortably get 2 million or more posts in before causing crashes....

Wow. That's a lot of spam. Must get busy

Tizzy
27-07-2007, 09:25:01
You can do it. I have faith in you.

Aredhran
27-07-2007, 09:28:48
Originally posted by KrazyHorse

0000 = -7
0001 = -6
0010 = -5
0011 = -4
0100 = -3
0101 = -2
0110 = -1
0111 = 0
1000 = 1
1001 = 2
1010 = 3
1011 = 4
1100 = 5
1101 = 6
1110 = 7
1111 = 8


Strange encoding there. 0000 = -7 :confused:

Resource Consumer
27-07-2007, 09:37:58
it's in base i^k

Dyl Ulenspiegel
27-07-2007, 09:46:36
Originally posted by VetLegion-
You know you've done too much programming when...

...you notice that "Word Association I - Forum Addiction" thread has reached 32332 replies and you think to yourself: boy, I hope they used an unsigned or a long!

:smoke:

I understood roughly what he means. Computer classes in 1986, or so. :eek:

Scabrous Birdseed
27-07-2007, 09:56:24
Originally posted by Dyl Ulenspiegel
I understood roughly what he means. Computer classes in 1986, or so. :eek:

Yeah me too, although in my case it's more like 1995.

VetLegion-
27-07-2007, 16:53:20
Originally posted by Lazarus and the Gimp
What? What sort of jibber-jabber is this?

KH's explanation is better.

KrazyHorse
27-07-2007, 21:36:28
Originally posted by Aredhran
Strange encoding there. 0000 = -7 :confused:

I'm not an expert in this, but I believe that's the way it's done

VetLegion-
27-07-2007, 23:14:56
Usually bits go from 2^0 to 2^n in sequence from right to left (I think it is from right to left, but it is not too important). So in your 4 bit example it would be:

001 = 1 (1 * 2^0 + 0 * 2^1 + 0 * 2^2)
010 = 2
011 = 3
100 = 4
101 = 5 (1 * 2^0 + 0 * 2^1 + 1 * 2^2)
110 = 6
111 = 7 (1 * 2^0 + 1 * 2^1 + 1 * 2^2)

When the sign is 0 the number would be positive and when sign is 1 the number would be negative. thus 0111 = 7, 1111 = -7. 0000 would be 0.

It is not necessarily the way I described, as it depends on the architecture of the processor, but bits generally do have meaning depending on their position.

Tau Ceti
28-07-2007, 00:17:23
The usual way is to use twos complement. To make a number negative, you

1) invert all bits
2) add 1.

Thus:

1000 = -8
1001 = -7
1010 = -6
1011 = -5
1100 = -4
1101 = -3
1110 = -2
1111 = -1
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7

This representation has the advantage of having a single value of 0, rather than having both positive and negative versions. (And 0 will certainly always be represented by only 0s. 0111? :clueless:)

KrazyHorse
28-07-2007, 03:01:21
Interesting...

VetLegion-
28-07-2007, 07:54:12
Tau Ceti is correct, I just checked with the calculator :beer:

Lazarus and the Gimp
28-07-2007, 07:58:44
Originally posted by KrazyHorse
Interesting...

You sick, twisted fuck.

Oerdin
28-07-2007, 08:16:44
What sort of rubbish is this? Is there porn involved?

Greg W
29-07-2007, 09:06:21
. ...
.''.' . '.
. '' ".'.:I:.'.. '.
.'.:.:..,,:II:'.'.'.. '.
.':.'.:.:I:.:II:'.'.'.'.. '.
.'.'.'.'::.:.:.:I:'.'.'.'. . '
..'.'.'.:.:I::.:II:.'..'.'.. .
..'.'':.:.::.:.::II::.'.'.'.'.. .
..'.'.'.:.::. .:::II:..'.'.'.'.'. .
.':.''.':'.'.'.:.:I:'.'.'.'.'.. '.. ..
':. '.':'. ..:.::.::.:.'..' ':.'.'.. ..
.:.:.':'. '.:':I:.:.. .'.'. ': .'.. . ..
'..:.:'. .:.II:.:.. . .:.'. '.. '. . ..
.. :.:.'. .:.:I:.:. . . ..:..:. :..':. . '.
.:. :.:. .:.:I:.:. . . ..:I::. :: :: .. ..
.. :'.'.:. .:.:I:'. ..:.:I:. :: ::. . '.
'..:. .:.. .:II:' ,,;IIIH. ::. ':. .
.:.::'.:::..:.AII;, .::",, :I .::. ':. .
:..:'.:II:.:I: ,,;' ' .;:FBT"X:: ..:.. ':. . .
.. :':III:. :.:A"PBF;. . .P,IP;;":: :I:..'::. . ..
. .:.:II: A.'.';,PP:" . . ..'..' .: :.::. ':... . ..
. .: .:IIIH:. ' '.' . ... . .:. :.:.. :... .'
. .I.::I:IIA. .. ... ..::.'.'.'.: .. . .
.:II.'.':IA:. .. ..:. . .:.: .''.' .. . .
..::I:,'.'::A:. . .:'-, .-.:.. .:.::AA.. ..:.' .. .
':II:I:. ':A:. ..:' ''.. . : ..:::AHI: ..:..'.'.
.':III.::. 'II:.:.,,;;;:::::". .:::AHV:: .::'' ..
..":IIHI::. . "I:..":;,,,,;;". . .:AII:: :.:' . .
. . IIHHI:..'.'.'V::. ":;;;" ...:AIIV:'.:.' .. .
. . :IIHI:. .:.:.V:. ' ' . ...:HI:' .:: :. . ..
. . ':IHII:: ::.IA.. .. .A .,,:::' .:. .
:. ...'I:I:.: .,AHHA, . .'..AHIV::' . . : ..
:. '.::::II:.I:.HIHHIHHHHHIHHIHV:'..:. .I.':. .. '.
. . .. '':::I:'.::IHHHHHHHHMHMHIHI. '.'.:IHI.. ' ' '.
':... . ''" .::'.HMHI:HHHHMHHIHI. :IIHHII:. . . . .
:.:.. . ..::.' .IV".:I:IIIHIHHIH. .:IHI::'.': '.. . .
. .:.:: .. ::'.'.'..':.::I:I:IHHHIA.'.II.:...:' .' ... . '..
'..::::' ...::'.IIHII:: .:.:..:..:III:.'::' .' . .. . .
'::.:' .'' .. :IIHI:.:.. ..: . .:I:"' ...:.:. .. .. ..
.:..::I:. . . . .IHII:.:' .. ..".::.:II:.:. . ... . ..
.. . .::.:.,,...-::II:.:' . ...... . .. .:II:.:: ... .. ..
..:.::.I . . . .. .:. .... ...:.. . . ..:.::. :.. . ..
.'.::I:. . .. ..:.... . ..... .. . ..::. .. .I:. ..' .
.'':.: I. . .. ..:.. . . .. ..... .:. .:.. .:I.'.''..
. .:::I:. . . .. .:. . .. .. . ... .:.'.'I' . ...
. ::.:I:.. . . . ....:. . . .... .. .:...:.:.:. ''.''
'.'::'I:. . .. ....:. . .. . .. ..' .'.:..:.. '
:. . . .. .. .:.... . . .... ... . .:.:.:.. '.
:. . . . .. .:.... . . ........ .:.:.::. . .
:. . . . . . .. .::..: . ..:.. . ::.:.:.. . .
:.. . . . . . .. ..:.: .. .. .:. .. ':::.::.:. . .
':.. . . . . .. .. ...::' .. .. . .:. . V:I:::::.. . :.
::. . . .. .. ... .:.:: .. . . .. .. . VI:I:::::.. ''B
:.. . . .. ..:.. ..I:... . . . .. ... . VII:I:I:::. .'::
':.. . . . .. ..:..:.:I:.:. . . .. . .:. . VHIII:I::.:..':
::.. . . .. ..:..:.HI:. . . . .... . :HHIHIII:I::..:
':. . . .. .. ..:.:.:HI:. . . .. ..... . HHHHIHII:I::.'
:.. . . . .. .:.:.:.HI:. . . .. ... . IHHHHIHHIHI:'
:.. . . . .. ..:..IH:. . . .. .. ,,, . 'HHHHHHHHI:'
':.. . . .. ..:.:.:HI.. . . .. . :::::. MIH:"""'
:. . . . .. ..::.:.VI:. . . .. .:::'::. HIH
:.. . . .. .:.:.:.V:. . . . ...::I"A:. HHV
:. . . . .. ..:.:.V:. . . ....::I::'.HV:
:. . . . . .. .:..II:. . . . ....':::' AV.'
:.. . . .. ... .:..VI:. . . .. .:. ..:.AV'.
':.. . . .. ..:.:.:HAI:.:...:.:.:.:.AII:.
I:. . .. ... .:.:.VHHII:..:.:..:A:'.:..
IA.. . . .. ..:.:.:VHHHHIHIHHIHI:'.::.
'HA:. . . .. ..:.:.:HHHIHIHHHIHI:..:.
HIA: . . . .. ...:.VHHHIHIIHI::.:...
HIHI:. . .. ... .::.HHHIIHIIHI:::..
HII:.:. . .. ... .::VHHIHI:I::.:..
AI:..:.. . . .. ..:.VHIII:I::.:. .
AI:. ..:.. . . .. ..' VHIII:I;... .
AI:. . .:.. . . . ... VHIII::... .
.A:. . :.. . . .. .:.. VHII::.. .
A:. . . ::. .. .. . .:.. "VHI::.. .
.:.. . . :.. .:..... .::.. VHI:..
... . . . . . :.:. ..:. . .::.. VI:.. .
.. .. . . . . ...:... . .. . .:::. V:.. .
'.. .. . . .. ..:::.... .:. . ..::.. V.. .
. . .. . . . . .. ..:::A. ..:. . . .::.. :..
. .. .. .. . . . ... ..::IA.. .. . . ..::. :.. .
.. .. ... . . .. .... .:.::IA. . .. . ..:.::. :. .
. . . .. . . . .. ..:..:.::IIA. . . .. .:.::. :. .
.. . . . . . .. ... ..:.::I:IHA. . . . ..:.::. . .
.: .. . . . . ... .:.. .:I:IIHHA. . . .. .::I:. .
.::. . . . .. ..:. .::.:IIHIIHHHA. . .. ..:I:. . .
A::.. . . ...:..:.::I:IHIHIHHHHA. . . ..::I:. .
:HI:.. . . .. .:.:.::I:IHIHIIHIHHHA. . .. .::I:. ..
AI:.. .. . . .. .:.:.::II:IHIIIHIHIHHHA. . . ..::I:. ..
:HI:.. . . . . .. .::.:I:IHIHIIIHIHIIHHHA.. . .. .::I:. ..
AI:.:.. . . . ... .::.::I:IHIIHIHIHIHIHIHHA. . . ..::I:. .
HI:. .. . . . . .. .:..::IIHIHIHIIIIWHIIHHMWA. . . .:::I:. . .
HI:.. . . . . .. ..:.::I:IIHHIIHIHIHIHHMMW" '.. . ..:::II: . .
HI::.. . . . .. .:..:::IIHIHIIWIWIIWMWW" . .. . ..::III: . .
HI::... . . . . ... ..:.:::IIHIWIWIWMWMWW. . . . .. .:.:III. . .
II::.:.. . . . .. ......:..IHWHIWWMWMW".. . . . . '... .:.:IHI:.. .
II:I::.. . . . . .....::.:IHWMWWWMW:.. . . . . .:..:::IIHII..
:II:.:.:.. . . . ......:.:.:IWWMWWW:.:.. . . . . :...:.:IHHI:..
HI::.:. . . . . . ...:.::.::.VWMWW::.:.:.. . . .. . :.. ..:IHHI::.'-
HII::.:.. . . . .. .:..:.'. 'WWWI::.::.:.. . . . .. ':...:II:IIII::
III::.:... . . . ...:.:... . WII:I::.:.. . . .. . . :.:::...::.::
VII::.:.. . . . .. ...:.... VHI:I::.:.. . . ... .. .::.:..:.:..:
VII::.:.. . . . ..:.::.. . :HHII:I::.:.. . . .. .. .'::':......
III:I::.. .. . . .. .:.:.. . :VHIHI:I::.:... . . .. .. .':. .. .AH
AA:II:I::.. . . . .. ..:.. . . ::HHIHII:I::.:... .. .. ... .:.::AHHH
AHH:I:I::.:.. . . .. ..:.:.. . ::VHHHVHI:I::.:.:.. ..:. .::.A:.AHHHM
HHHAII:I::.:.. . . . .. ..:.. . . :::HIHIHIHII:I::.:.. .. .:. ..AHHMMM:
AHHHH:II:I::.:.. . . .. ..:.:.. . .:I:MMIHHHIHII:I:::.:. ..:.:.AHHHMMM:M
HHHHHA:II:I::.. .. . . .. .:... . .:IIVMMMHIHHHIHII:I::. . .. AHHMMMM:MH
HHHHHHA:I:I:::.. . . . ... ..:.. ..:IHIVMMHHHHIHHHIHI:I::. . AHMMMMM:HHH
HHHHHMM:I::.:.. . . . .. ...:.:...:IIHHIMMHHHII:.:IHII::. AHMMMMMM:HHHH
HHHHHMMA:I:.:.:.. . . . .. ..:.:..:IIHHIMMMHHII:...:::.:.AHMMMMMMM:HHHHH
HHHHHMMMA:I::... . . . . .. ..:.::.:IHHHIMMMHI:.:.. .::AHMMMMMMM:HHHHHHH
VHHHHMMMMA:I::.. . . . . .. .:.::I:IHHHIMMMMHI:.. . AHMMMMMMMM:HHHHHHHH
HHHMMMMMM:I:.:.. . . . . ...:.:IIHIHHHIMMMMMHI:.AHMMMMMMMMM:HHHHHHHHHH
HHHHMMMMMA:I:.:.. . . . .. .:IIHIHHHHIMMMMMH:AMMMMMMMMMMM:HHHHHHHHHHH
VHHHMMMMMMA:I:::.:. . . . .. .:IHIHHHHHIMMMV"AMMMMMMMMMMMM:HHHHHHHHHHHH
HHHHHMMMMMA:I::.. .. . . ...:.:IHHHHHHIM"AMMMMMMMMMMMM:HHHHHHHHHHHHHH
VHHHHHMMMMMA:I:.:.. . . . .. .:IHIHHHHI:AMMMMMMMMMMMIHHHHHHHHHHHHHHHH
VHHHHHMMMMMA:I::.:. . . .. .:.:IHHHV:MMMMMIMMMMMMMMMMMMMHHHHHHHHV::.

VetLegion-
29-07-2007, 09:59:51
:love: