Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Why use signed integers?

Name: Anonymous 2012-09-26 12:17

I've noticed that, in quite a few MMORPGs, the stackable item/money cap is (2^31)-1, or 2,147,483,647.

But why use a signed integer? Do you really need negative amounts of items?

Why not use unsigned integers and then have the cap be (2^32)-1?

Name: Anonymous 2012-09-26 12:19

Maybe they use unsigned integers but one less bit?
Or perhaps they use negative item sizes for some sort of special/error value, similar to EOF.

Name: Anonymous 2012-09-26 12:21

Because bethesda cant code


Why would you have 231-1 to begin with? Cheating as usual?

Name: Anonymous 2012-09-26 13:04

probably sepples codemonkeys who blindly use "int" for everything

Name: Anonymous 2012-09-26 13:16

Because anybody who gets paid to do anything is absolute shit at it. THREAD OVER

Name: Anonymous 2012-09-26 13:16

>>4
Oh no does this mean an extra four kilobytes of my memory will be taken up?!

Cool down, sperglord. A proper, modern compiler like gcc will optimize that shit anyway.

Name: Anonymous 2012-09-26 13:19

>>5
Confirmed.

Source: I'm a programmer and I suck at it.

Name: Anonymous 2012-09-26 13:20

>>6
Wait, do compilers really optimize types?

I'd like to know if I've been wasting mental resources unnecessarily by using char in C for storing small numbers.

Name: Anonymous 2012-09-26 13:26

>>8
Only for compile-time constants

The compiler modifying types anywhere else would be non-standard and harmful.

Name: Anonymous 2012-09-26 13:31

>>9
that makes sense. could it be that >>6-kun is just spewing the ``don't do anything because the compiler optimizes it'' bullshit without actually shit about it?

Name: Anonymous 2012-09-26 13:44

>>9
The compiler could change the type and still comply with the standard in code like this:
for(int i = 0; i < 100; ++i) {
  /* some code that doesn't modify or take the address of i */
}

Name: Anonymous 2012-09-26 14:05

>>10
That's exactly what I was doing. I am very proud of you.

Name: Anonymous 2012-09-26 14:31

>>11
i doesn't even have to be stored anywhere. The loop could be unrolled 100 times and it would still be compliant.

Name: Anonymous 2012-09-26 14:37

>>11
``i'' is in a register.

Name: Anonymous 2012-09-26 14:40

>>14
Postulation.

Name: Anonymous 2012-09-27 1:39

>>1
You sign the integers to prevent players from hacking their inventory.

Name: Anonymous 2012-09-27 3:13

>>16

lel

Name: Anonymous 2012-09-27 4:51

>>17
Leave your ``lel''s back at Reddit.

Name: Anonymous 2012-09-27 6:39

>>1
Because they're retards.

Name: 19 2012-09-27 6:41

Actually, perhaps they use a non-conservative garbage collector and one of the bits is a type tag. Or the servers are running on a machine whose word size is 31 bits.

Name: Anonymous 2012-09-27 6:55

Maybe 4.3 billion is just too much gold.

Name: Anonymous 2012-09-27 6:55

>>20
Name one architecture that has that.

Name: Anonymous 2012-09-27 7:00

>>22
A few languages specify 31-bit integers.
True, it's not the architecture, but >>20 is just a baka. I suspect most dedicated game servers are 64-bit, and have been for quite a few years.

Name: Anonymous 2012-09-27 8:16

>>21
maybe your mother sucks cocks in hell

Name: Anonymous 2012-09-27 11:58

People like to use -1 and some languages don't have an unsigned primitive type

Name: Anonymous 2012-09-27 14:01

So why does EOF need to be -1? Why not make it ASCII 3, 4, 25, or some similar control character?

Name: Anonymous 2012-09-27 16:16

If you do not [u]int[8,16,32,64] instead of any other integer number type then you need to go fuck yourself.

Name: Anonymous 2012-09-27 16:17

>>26
because your integers in MMORPGs need to express quantities that can range any sensible natural number, including 3, 4 and 25

Name: Anonymous 2012-09-27 16:20

>>26
Are you serious? If you open a file and you count the number of characters on it, it can be any number from 0 to infinity and EOF can't use any of those numbers.

Name: Anonymous 2012-09-27 17:56

>>29
Shalom!

Name: Anonymous 2012-09-27 18:16

>>29
the number of characters
What does this have to do with anything? When checking for EOF, programs loop through each individual character. That's what it's for.

Name: Anonymous 2012-09-27 18:17

Thanks, >>30-kun. I was waiting your reply. Your reply made my day.

Name: Anonymous 2012-09-27 18:19

>>31
Oh I mixed up FILE* and the int counter for some stupid reason. Sorry.

Name: Anonymous 2012-09-27 18:56

>>26
Someone could make an I/O library (not stdio compatible) that does this for text files, but binary files need the ability to store any character, including the control characters.

Name: Anonymous 2012-09-27 20:31

>>23
Just because a server uses a 64-bit CPU and OS doesn't mean its users do. Many people still use old CPUs with 32-bit bus widths, and thus still use 32-bit OSes and require 32-bit game clients.

Name: Anonymous 2012-09-27 20:41

>>35
Implying there's no such thing as carry bits

Name: Anonymous 2012-09-27 21:08

>>36
get your retarded ass back to /g/ please

Don't change these.
Name: Email:
Entire Thread Thread List