Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

The Management posted:

true on some architectures

how's the carter administration?

Adbot
ADBOT LOVES YOU

The Management
Jan 2, 2010

sup, bitch?

Cocoa Crispies posted:

i straight up never know what sizes c variables are anymore so last time i wrote c i typedef'd u8, s8, f64, etc. and just asserted their sizeof during startup tests

jfc. not knowing stdint is basically a fail during the interview.

Sweeper posted:

which one

actually I can't seem to find any.

spiritual bypass
Feb 19, 2008

Grimey Drawer
z80 or something idk

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

rt4 posted:

z80 or something idk

ya, sega genesis runs into integer overflows at 255 in lots of games so i assume it's base int was that small

The Management
Jan 2, 2010

sup, bitch?

cis autodrag posted:

ya, sega genesis runs into integer overflows at 255 in lots of games so i assume it's base int was that small

genesis is 68000, 16 bit processor. but developers frequently used bytes for various counters because RAM is extremely limited

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

The Management posted:

genesis is 68000, 16 bit processor. but developers frequently used bytes for various counters because RAM is extremely limited

why did i think it was a z80. well, i never was much for memorizing hardware genealogies. i just tend to notice all the speed run tricks that revolve around overflows.

minivanmegafun
Jul 27, 2004

cis autodrag posted:

why did i think it was a z80. well, i never was much for memorizing hardware genealogies. i just tend to notice all the speed run tricks that revolve around overflows.

I think the master system was a z80?

hobbesmaster
Jan 28, 2008

The Management posted:

jfc. not knowing stdint is basically a fail during the interview.


actually I can't seem to find any.

i was going to say "int" in C is 16 bits at a minimum, I don't think any languages called something that can be 8 bits an "integer"

The Management
Jan 2, 2010

sup, bitch?

hobbesmaster posted:

i was going to say "int" in C is 16 bits at a minimum, I don't think any languages called something that can be 8 bits an "integer"

C does not define the size of an int. it defines that the size relationship must be:

char <= short <= int <= long int

sizeof(char) must equal 1, and it must be at least 7 bits to contain the ascii charset.

I used to work on a dsp where char, short, and int were all 16 bits and sizeof on all of them evaluated to 1.

The Management
Jan 2, 2010

sup, bitch?
anyway, there are standard sizes. use them.

code:

#include <stdint.h>

and if I see you converting a pointer to an int in an interview know that I am emailing the recruiter to walk you out after I'm done.

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

one of you is an idiot who's huffed too many farts but I don't program so I can't talk which one

hobbesmaster
Jan 28, 2008

The Management posted:

C does not define the size of an int. it defines that the size relationship must be:

char <= short <= int <= long int

sizeof(char) must equal 1, and it must be at least 7 bits to contain the ascii charset.

I used to work on a dsp where char, short, and int were all 16 bits and sizeof on all of them evaluated to 1.

http://port70.net/~nsz/c/c89/c89-draft.html#2.2.4.2

travelling wave
Nov 25, 2013

The Management posted:

and if I see you converting a pointer to an int in an interview know that I am emailing the recruiter to walk you out after I'm done.

what if it's an aligned pointer and I want to store some extra information in the low bits? what then smart guy????????

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

The Management posted:

and if I see you converting a pointer to an int in an interview know that I am emailing the recruiter to walk you out after I'm done.

what if I leave a comment right above it saying "yolo"?

The Management
Jan 2, 2010

sup, bitch?

travelling wave posted:

what if it's an aligned pointer and I want to store some extra information in the low bits? what then smart guy????????

then you better use a uintptr_t, not an int.

JewKiller 3000
Nov 28, 2006

by Lowtax
what if i value an understanding of c semantics but i don't program in c regularly enough to remember all the proper typedef nonsense and i sure as gently caress don't want to either? and it's not relevant to my job in any way whatsoever? what then smart guy???

Notorious b.s.d.
Jan 25, 2003

by Reene

cis autodrag posted:

why did i think it was a z80. well, i never was much for memorizing hardware genealogies. i just tend to notice all the speed run tricks that revolve around overflows.

the genesis had both a 68k and a z80, and either one could act as the CPU. that was how master system backwards compatibility worked

this is also why the main sound chip was attached directly to the z80 -- that's how it was on the master system

all genesis games and emulators use the z80 for sound, if nothing else

The Management
Jan 2, 2010

sup, bitch?

JewKiller 3000 posted:

what if i value an understanding of c semantics but i don't program in c regularly enough to remember all the proper typedef nonsense and i sure as gently caress don't want to either? and it's not relevant to my job in any way whatsoever? what then smart guy???

then I wouldn't be interviewing you because you are useless to me.

big shtick energy
May 27, 2004


Captain Foo posted:

one of you is an idiot who's huffed too many farts but I don't program so I can't talk which one

The Management is correct here

I'll sometimes use an int for simple iterators like for(int i=0; i < SOME_CONST; i++) since I assume the compiler would warn me if the int somehow wasn't big enough, although "I assume the compiler would..." is a bad phrase when it comes to C

qhat
Jul 6, 2015


Wrt the stdint debate, can we just all agree that mistaking an int for a one byte char is instant grounds for removal from the premises/telephone line?

qhat
Jul 6, 2015


If you honestly gently caress up on an ultra basic question in that way, then the only logical conclusion that can be drawn from that is "this person has absolutely no idea what they are talking about"

Bhodi
Dec 9, 2007

Oh, it's just a cat.
Pillbug
my response would be: "sorry, I program in a modern OS and so don't concern myself with such trivialities"

and then my interviewers will stand up and clap

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

qhat posted:

Wrt the stdint debate, can we just all agree that mistaking an int for a one byte char is instant grounds for removal from the premises/telephone line?

it's totally reasonable to assume that an int would be 8 bits on an 8 bit processor, though in practice that turns out not to be the case. the (C++) standard does not prevent this from being the case.

moreover there are 8 bit integer types, so depending on context it may be fine to refer to these as ints.

I'm curious why you care that people have every type's size memorized when they should be using sizeof and/or be using objects with a well defined size anyway. I could care less if someone has memorized how many bits of mantissa a float or double have as well.


when the correct answer to your weeder question is: "it depends on the architecture, language, and in some languages, the compiler" (alternatively: "why are you using 'int'?") then you've got a couple problems and the candidate may not be one of them.

hobbesmaster
Jan 28, 2008

leper khan posted:

it's totally reasonable to assume that an int would be 8 bits on an 8 bit processor, though in practice that turns out not to be the case. the (C++) standard does not prevent this from being the case.

only in the most fishmechian "the c++ standard says that the integer limits are the same as C" way

qhat
Jul 6, 2015


leper khan posted:

it's totally reasonable to assume that an int would be 8 bits on an 8 bit processor, though in practice that turns out not to be the case. the (C++) standard does not prevent this from being the case.

moreover there are 8 bit integer types, so depending on context it may be fine to refer to these as ints.

I'm curious why you care that people have every type's size memorized when they should be using sizeof and/or be using objects with a well defined size anyway. I could care less if someone has memorized how many bits of mantissa a float or double have as well.


when the correct answer to your weeder question is: "it depends on the architecture, language, and in some languages, the compiler" (alternatively: "why are you using 'int'?") then you've got a couple problems and the candidate may not be one of them.

In C++, without any length modifiers, the width of an int is guaranteed to be at least 16bits. As for 8 bit processors, we tend to deal in reality, not fantasy. If you go for a C/C++ job and you don't know the size of the most fundamental datatypes in the language (obviously given a known architecture) then you are a terrible C programmer and an instant fail.

qhat
Jul 6, 2015


employers just shouldn't ask any questions really since it's obviously impossible to gauge someone's understanding by asking them the most utterly basic questions about a language

MeruFM
Jul 27, 2010
moreso than bad interview questions, I wish it was easier to fire people once you realize they're poo poo instead letting them stay forever and making everyone else hate their job a bit more or leaving.

Arcsech
Aug 5, 2008

qhat posted:

In C++, without any length modifiers, the width of an int is guaranteed to be at least 16bits. As for 8 bit processors, we tend to deal in reality, not fantasy. If you go for a C/C++ job and you don't know the size of the most fundamental datatypes in the language (obviously given a known architecture) then you are a terrible C programmer and an instant fail.

tbh never ever use the "int" type for anything in c/c++. it's a code smell. always always always in every circumstance use (u)intXX_t. if I need to know what size an "int" is on my platform I'll look it up and then change the code in question to use the correct type instead

e: size_t and friends are also acceptable

Arcsech fucked around with this message at 04:24 on Jun 26, 2017

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
why are types in c so convoluted anyway? is the answer "int was once upon a time a thin wrapper over a hardware register size"?

JewKiller 3000
Nov 28, 2006

by Lowtax
basically, yeah. most architectures implement "int" as "machine word" which means you can't rely on a specific size for int cross-platform

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
I'd get nervous on answering immediately the size of int, I'd need to think for a bit

(ok char is 256, OBVIOUSLY because ascii and stuff, so 8 bits. then short is double that 16, and int is double that... then 32. cue in talk about architectures here)

I'm just used to typing u16, i32 etc that I never think about the basic types anymore

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

qhat posted:

employers just shouldn't ask any questions really since it's obviously impossible to gauge someone's understanding by asking them the most utterly basic questions about a language

this but unironically

hobbesmaster
Jan 28, 2008

Symbolic Butt posted:

I'd get nervous on answering immediately the size of int, I'd need to think for a bit

(ok char is 256, OBVIOUSLY because ascii and stuff, so 8 bits. then short is double that 16, and int is double that... then 32. cue in talk about architectures here)

I'm just used to typing u16, i32 etc that I never think about the basic types anymore

CHAR_BIT is at least 8bits

one of those factoids you follow up with "I hope this is never relevant"

JewKiller 3000
Nov 28, 2006

by Lowtax
ascii only uses 7 bits so i hope you like signed char

Notorious b.s.d.
Jan 25, 2003

by Reene

cis autodrag posted:

why are types in c so convoluted anyway? is the answer "int was once upon a time a thin wrapper over a hardware register size"?

nearly everything in c is a thin wrapper over an idealized set of dec hardware from the 1970s

writing pdp-11 assembly looks a lot like C right off the top, even down to the dumbassery with array[idx] vs idx[array]

RISCy Business
Jun 17, 2015

bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork
Fun Shoe

JewKiller 3000 posted:

ascii only uses 7 bits so i hope you like signed char

i prefer my chars autographed

FMguru
Sep 10, 2003

peed on;
sexually

RISCy Business posted:

i prefer my chars autographed
theres been a real downturn in signed chars since smartphones became a thing

people just take selfies with the chars now

RISCy Business
Jun 17, 2015

bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork
Fun Shoe

FMguru posted:

theres been a real downturn in signed chars since smartphones became a thing

people just take selfies with the chars now

millenials are killing the autograph industry

Joe 30330
Dec 20, 2007

"We have this notion that if you're poor, you cannot do it. Poor kids are just as bright and just as talented as white kids."

As the audience reluctantly began to applaud during the silence, Biden tried to fix his remarks.

"Wealthy kids, black kids, Asian kids -- no, I really mean it." Biden said.
Can we get this back on topic with more videogame chat

Adbot
ADBOT LOVES YOU

redleader
Aug 18, 2005

Engage according to operational parameters

qhat posted:

Wrt the stdint debate, can we just all agree that mistaking an int for a one byte char is instant grounds for removal from the premises/telephone line?

what do you mean by 'mistaking' an int for a char? because in this very thread

The Management posted:

I used to work on a dsp where char, short, and int were all 16 bits and sizeof on all of them evaluated to 1.

  • Locked thread