← Home ← Back to /g/

Thread 106581206

86 posts 20 images /g/
Anonymous No.106581206 [Report] >>106581336 >>106581766 >>106582011 >>106582123 >>106582178 >>106583516 >>106583604 >>106583619 >>106586475 >>106587685 >>106587965 >>106590583 >>106590717 >>106591519
How brown do you have to be to write an entire book on c, get it published, and then publish a second edition and you don't even know the definition of c data types.
Anonymous No.106581242 [Report] >>106588242 >>106591805
>float: To store floating point numbers
>double: To store big floating point numbers
Anonymous No.106581245 [Report]
what book is that
Anonymous No.106581336 [Report] >>106581445
>>106581206 (OP)
>brown
That would be python
Anonymous No.106581445 [Report] >>106582494 >>106585822
>>106581336
Python is for women and coding boot camp graduates.
Anonymous No.106581581 [Report]
ranges are wrong too
Anonymous No.106581766 [Report] >>106582930 >>106583493
>>106581206 (OP)
what's the problem?
it describes "a" version of C instead of the latest
Anonymous No.106581781 [Report] >>106581951
Packt Publishing?
Anonymous No.106581951 [Report]
>>106581781
oxford university publishing
Anonymous No.106582011 [Report] >>106582194 >>106583532
>>106581206 (OP)
2 byte ints? What is this, the 80s.
Of course ints should be 8 bytes now but in the biggest fuck-up in programming they held them a 4 bytes going to 64 bit architectures except for cray’s C compiler who did the right thing.
Anonymous No.106582086 [Report] >>106583493 >>106586074
those are the minimum guaranteed sizes for c ints

if you care about the actual size of something use stdint.h
Anonymous No.106582123 [Report] >>106586074
>>106581206 (OP)
anyone can write anything they like. it's up to publishers to at least do the bare minimum of proof reading, using someone with experience with whatever topic, before releasing it.
Anonymous No.106582178 [Report]
>>106581206 (OP)
>char for characters
Jej
Anonymous No.106582194 [Report]
>>106582011
32bit goes faster
Anonymous No.106582494 [Report] >>106586107
>>106581445
>Python is for women and coding boot camp graduates.
That's just horrible
Anonymous No.106582930 [Report] >>106582959
>>106581766
The problem is that if you use a normal, modern computer, the table is going to be very wrong
Anonymous No.106582959 [Report] >>106590672
>>106582930
Reminder that C is a PDP11 emulator
Anonymous No.106583493 [Report] >>106583876 >>106586074
>>106581766
It describes a spec that doesn't exist, so it is wrong by definition. Every programmer should know this, especially if you're going to write a fucking book.
>>106582086
This is the only sane comment in this thread
Anonymous No.106583516 [Report] >>106586074
>>106581206 (OP)
Which book is this?
Anonymous No.106583532 [Report] >>106587627
>>106582011
>in the biggest fuck-up in programming they held them a 4 bytes going to 64 bit architectures
using 64 bits for no reason increase your code size because of rex prefix
for 99% of cases it's useless and the other 1% you use ULONGLONG/LONGLONG data type
Anonymous No.106583604 [Report] >>106583862 >>106584842
>>106581206 (OP)
>you don't even know the definition of c data types.
That table is so wrong.
char: At least 8 bits. (It can be more, but it's usually 8).
int: At least 16 bits (must hold at least -32767 to 32767).
long: At least 32 bits.
long long (C99+): At least 64 bits.
Anonymous No.106583616 [Report]
come home white men
Anonymous No.106583619 [Report]
>>106581206 (OP)
>How brown do you have to be
How many books have you published?
Anonymous No.106583862 [Report]
>>106583604
that table is also wrong
Anonymous No.106583876 [Report] >>106584135
>>106583493
>It describes a spec that doesn't exist, so it is wrong by definition
the absolute state of cs undergrads these days...
Anonymous No.106584135 [Report]
>>106583876
okay, show me. you won't, because you can't.
>cs undergrads
why are you thinking about zoomers so much?
Anonymous No.106584842 [Report] >>106585576
>>106583604
A char is universally 8 bits though, right?
Anonymous No.106585232 [Report] >>106586074
next time point out the error
not everyone autistically memorized the byte size of their data types
and no you have never needed to know it so don't pretend otherwise
Anonymous No.106585576 [Report]
>>106584842
Today, but not historically. Thus, C never defined them as 8 bits
https://en.wikipedia.org/wiki/Byte
Anonymous No.106585822 [Report]
>>106581445
Correct
Anonymous No.106586074 [Report] >>106586177 >>106586304
>>106582086
>>106583493
Signed int has no guarantee that -32768 will be representable; the standard clearly states that one’s complement is allowed.
>>106585232
It's the most basic shit in the entire language if you don't know this you have no business programming and definitely no business writing a book on data structures in c.
>>106583516
https://github.com/GauravWalia19/Free-Algorithms-Books/blob/main/Library/src/C/Data-Structures-Using-C-2nd-edition.pdf
>>106582123
Publisher is OUP the west has fallen.
Anonymous No.106586107 [Report]
>>106582494
>That's just horrible

You must be new here
Anonymous No.106586177 [Report] >>106586233 >>106593049
>>106586074
yeah i don't write in c because i got a job so just tell me what the issue is instead of expecting others to know the specification of an outdated tutorial language

and don't lump me in with the others in your reply. that's rude and disrespectful
Anonymous No.106586233 [Report] >>106586322
>>106586177
Sorry, I meant if you don't know the specification of the data types in ANY language then you have no business programming. Period.
Anonymous No.106586304 [Report] >>106586383
>>106586074
>Signed int has no guarantee that -32768 will be representable; the standard clearly states that one’s complement is allowed.
not since C23, only two's complement is allowed now (but signed overflow is still UB because lol committees)
Anonymous No.106586318 [Report]
Arduino is C++, but if you forgive it, On ATmega-based CPU's (Arduino Uno, Nano, Mega) an int is 2 bytes (I would assume the raspberry pi equivariant C compiler would be the same? but the only raspberry pi I looked at was the pico rp2040 which is 32bit arm, and I bet GCC / clang refuses to use 2 byte ints on C11).
Anonymous No.106586322 [Report] >>106586383 >>106586390 >>106593078 >>106593303
>>106586233
lol there is no practical reason to memorize the byte size of a data type. i mean i get it that you probably had to know it for the exam you had last week but usually people forget about inconsequential stuff like that and simply look it up when they need it. which is in 99% of all cases NEVER

you're just being a pseud and circlejerking the fact that you spotted an error in a textbook because it makes you feel extra smart because you don't have any other tangible achievements
Anonymous No.106586383 [Report] >>106586405
>>106586304
This is how I would expect a book to explain signed integers from c17 to c23 (left) situation. The book in the OP was published in 2014 and seems to be describing a language that doesn't exist.
>>106586322
You are fucking delusional, I hope you failed your exam so I never have to see your buggy code in a critical system.
Anonymous No.106586390 [Report] >>106586405
>>106586322
>there is no practical reason to memorize the byte size of a data type
most retarded statement posted on /g/ this month award
Anonymous No.106586405 [Report] >>106586434 >>106586435
>>106586383
>>106586390
your autistic low level hobby project isn't a critical system
Anonymous No.106586434 [Report] >>106586451
>>106586405
i pity the critical system touched by a person who can't remember whether a data type can store numbers in the thousands range or hundred millions range
Anonymous No.106586435 [Report] >>106586469
>>106586405
>t. writes if ( a + b > UINT_MAX ) instead of if ( a > UNIT_MAX - b )
It's a good thing you don't use c. I hope you don't use c++ either. You are going to need the most nanny compiler if you ever want to start writing real code.
I hope for your sake and your users sake that you use rust or a managed language.
Anonymous No.106586451 [Report]
>>106586434
you keep repeating the word "critical system" like it's some magic word that will make you not sound unemployed
Anonymous No.106586454 [Report] >>106586465
>Reema
>AP at a college for women
An Indian woman? Writing a book on c? KEK this is going to be hillarious
of course /g/ is defending this
Anonymous No.106586465 [Report]
>>106586454
>Data types in c? Who the fuck needs to know that beyond university students!1!
LMAO
Anonymous No.106586469 [Report] >>106588259
>>106586435
yeah because that's totally code that you'll find in real applications and not in your practice problems meant to teach you basic programming concepts

>what? you don't remember the lullaby they use to teach the alphabet? pfff do you even write CRITICAL text?
Anonymous No.106586475 [Report] >>106586602
>>106581206 (OP)
This is correct for 16bit MCUs.
Anonymous No.106586602 [Report] >>106586671 >>106588431
>>106586475
What if it uses one's complement?
Anonymous No.106586671 [Report]
>>106586602
Unisys OS 2200 seems to be produced in 2023 but it was first released in 1967, and I don't know how much C is being used, or which standard of C or compiler it uses (it seems to be the platform for COBOL banking systems that just work and they don't want to risk replacing it).
Anonymous No.106587627 [Report] >>106587941
>>106583532
> oh no increase code size!
You probably said that exact same shit when we moved from 16 bit systems to 32 bit systems.
Or, more likely, you were still debugging COBOL on a 36-bit mainframe at that time and didn't care.
This ought to send you over the edge:
typedef int bool;
Anonymous No.106587685 [Report] >>106587999 >>106591519
>>106581206 (OP)
>char is supposed to store characters not numbers, so why this range? The answer is that in the memory, characters are stored in their ASCII codes.

You can already tell from just the first sentences on the page that this book is total shit
Anonymous No.106587941 [Report] >>106590934
>>106587627
>oh no increase code size!
oh no is right, on x86-64 or aarch64 or risc-v if your code is running it will be in L1i which is only 32kb (maybe 64kb)
That's what modern computers look like. They are still machines with small memory
Anonymous No.106587965 [Report]
>>106581206 (OP)
Use case for learning all dat when LLMs exist?
Anonymous No.106587999 [Report] >>106588272 >>106589504 >>106590709
>>106587685
What's the problem? c stores ASCII characters in char, stop with the autism
what does
char c = 'c' ;
do?
You know exactly what she means "For example, the character 'A' has the ASCII code of 65. In memory we will not store 'A' but 65 (in binary number format)"
>b-b-b-b-ut I might not use ASCII!
Cries the language pedant as I stomp a job application into his skull with my thick boot.
Anonymous No.106588242 [Report]
>>106581242
This triggers me. The reason I use double for strains and shit in solvers is not because they are big
Anonymous No.106588259 [Report] >>106590112
>>106586469
You find such overflow checks in any program that parses any byte format or text formats such as json, or the Linux kernel or any untrusted data for a client/server. But I guess you are just a code monkey that glues code together made by others so you don't have to understand it.
Anonymous No.106588272 [Report] >>106588337 >>106588381
>>106587999
What encoding does it actually use? Is it UTF-8 or UTF-16 on Windows or something else?

For illustrative purposes it's probably fine to talk about ASCII encoding though as it's simple to understand.
Anonymous No.106588337 [Report] >>106588381
>>106588272
It's up to the compiler, if your source is encoded in EBCDIC or whatever gcc won't be able to tell (assuming the rest of your code is in ascii or utf8 if not it will just fail to compile) gcc support ascii and utf8 and maybe some others. Of course if you are using char it will convert the utf8 encoding to ascii.
C is very flexible when it comes to encodings all it requires is that a certain set of characters is supported and that you translate all source code into that set.
Anonymous No.106588381 [Report]
>>106588337
>>106588272
for example if you wanted to you could make a standard compliant c compiler that only accepts emoji which gets translated to the basic character set (or higher level macros/functions) and you can encode the basic character set in a way that nobody would be able to write to by default with a keyboard
Anonymous No.106588431 [Report] >>106588489
>>106586602
Clearly that machine that implementation is for does not, otherwise the rangers would be different.
Anonymous No.106588489 [Report]
>>106588431
Is it clear? What if the machine has 2 operating modes with distinct signed integer representation?
Anonymous No.106589504 [Report]
>>106587999
The problem is that 'ascii codes' doesn't have anything to do with the range being -128 to 127.
Anonymous No.106590112 [Report] >>106590735
>>106588259
if you had any real world experience you'd know that it would be trivial not to fuck that kind of code up if one wrote even a single test. besides it doesn't have anything to do with the specific byte size of a data type but only the fact that there is a max/min limit so your text comprehension is lacking too

whatever i'm done with your midwit ass. go finish school and maybe you'll stop being a retard. until then you'll fit right in with the gee crowd
Anonymous No.106590583 [Report] >>106590712
>>106581206 (OP)
Also how does it use the "basic data type" term here without explaining it? I get that in the Note, they are saying when you type long var, you're actually saying "long int var", because "the basic data type" of long is ... int? Badly written.
Anonymous No.106590672 [Report]
>>106582959
Which is perfectly fine, because almost every modern computer is similar to a PDP-11 (Von Neumann architecture).

People who parrot this sentence typically write in languages that also make the same assumptions, and not in fucking Chapel or GLSL or whatever.
Anonymous No.106590709 [Report]
>>106587999
The proper answer is that C has tons of valid concepts, but often with retarded and misleading names, for historical reasons.

This has been fixed using typedefs and macros to have more correct names, but the keywords are immutable.
Anonymous No.106590712 [Report]
>>106590583
It's saying when anything from the table 1.2 is omitted int is assumed (implicit int) which isn't hasn't been true since C90.
int main() is a declaration that isn't assumed.
I don't think long main will work for a hosted program, but idk. Compcert gives a warning so I doubt it.
In practice every compiler probably supports long main() though.
Anonymous No.106590717 [Report]
>>106581206 (OP)
>How brown do you have to be to write an entire book on c, get it published, and then publish a second edition and you don't even know the definition of c data types.
>t.
Anonymous No.106590735 [Report] >>106590753 >>106590836
>>106590112
>if you had any real world experience you'd know that it would be trivial not to fuck that kind of code up

It's not trivial at all.
A good example is to look at OpenBSD erratas. Like this one:

https://ftp.openbsd.org/pub/OpenBSD/patches/7.7/common/004_pfsyncook.patch.sig

This was not some old code inherited from BSD 25 years ago, it's a bug in code they wrote recently.

This is a project that is known for its code auditing and code reviews practice, and its programmers are known to be some of the most competent C programmers.
Anonymous No.106590753 [Report]
>>106590735
>c programmers writing c: um actually the type blah blah blah
>c programmers writing make: works on my machine
KEK
Anonymous No.106590836 [Report] >>106593049
>>106590735
still has nothing to do with the specific byte size of a particular data type. are you dense or something? and for fucks sake if you quote me then quote the full sentence. is your pride that hurt?

at least you're in a profession where it's somewhat tolerated to be a smug pedantic nerd but don't expect to get coddled like mommy and daddy did who don't really get what their autistic son is talking about but are proud of him for being such a smart cookie

next time simply point out where the error is instead of assuming everyone memorized the byte sizes of the data types of a particular language

and again this kind of error would have been easily caught if someone wrote a simple test for it. i don't care about the reputation of a project and neither should you. also inb4 you ignore everything else i wrote and focus on this part of my post just so you can get a teenie tiny win
Anonymous No.106590934 [Report]
>>106587941
> code size
what is the Thumb 1 and Thumb 2 instruction sets?
Anonymous No.106591519 [Report] >>106591533 >>106592496
You can't make this shit up. It's lifted from an older Indian book C In Depth by Srivastava
>>106587685
>>106581206 (OP)
Anonymous No.106591533 [Report]
>>106591519
Literally stolen from this book with the machine and range qualifiers removed. LMAO
Anonymous No.106591559 [Report]
that book is correct. read the C standard, plebs.
Anonymous No.106591805 [Report]
>>106581242
>0.000000000000000000000000000001 is very big number, saar
Anonymous No.106592496 [Report]
>>106591519
Found it again in another book, Indian author again.
Anonymous No.106592614 [Report]
Why are Indians like this?
I instinctively know to avoid book if I see Indian name unless it's written by some popular one who is well regarded. Despite the Chinese being known as culture with no honour that has cheating integrated deeply into their society they still write great books.
No other race/culture makes me feel like this.
Anonymous No.106593049 [Report] >>106593055 >>106593081
>>106586177
and don't lump me in with the others in your reply. that's rude and disrespectful
>>106590836
>and for fucks sake if you quote me then quote the full sentence.
if bait then it's of excellent quality and made me reply. if not, then gtfo to back facebook boomer retard.

also
>muh job
>muh half-assed unit tests
not knowing the spec of the language you work with is a sign of crass incompetence, even if you have decades of supposed "work experience".
Anonymous No.106593055 [Report]
>>106593049
*gtfo back to facebook
Anonymous No.106593078 [Report] >>106593094
>>106586322
it's not like anyone actually sits down to memorize that shit, people just pick it up through repetition unless they have the comprehension skills of a toddler
Anonymous No.106593081 [Report] >>106593348
>>106593049
i accept your concession
Anonymous No.106593094 [Report] >>106593183
>>106593078
i'm sure the size of an int plays a big role in your hobby project
Anonymous No.106593183 [Report] >>106593348
>>106593094
sneethe
Anonymous No.106593303 [Report] >>106593348
>>106586322
>
Anonymous No.106593348 [Report]
>>106593303
>>106593081
>>106593183