[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


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.
>>
>float: To store floating point numbers
>double: To store big floating point numbers
>>
what book is that
>>
>>106581206
>brown
That would be python
>>
>>106581336
Python is for women and coding boot camp graduates.
>>
ranges are wrong too
>>
>>106581206
what's the problem?
it describes "a" version of C instead of the latest
>>
Packt Publishing?
>>
>>106581781
oxford university publishing
>>
>>106581206
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.
>>
those are the minimum guaranteed sizes for c ints

if you care about the actual size of something use stdint.h
>>
>>106581206
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.
>>
>>106581206
>char for characters
Jej
>>
>>106582011
32bit goes faster
>>
File: 1733128157649098.png (250 KB, 718x588)
250 KB
250 KB PNG
>>106581445
>Python is for women and coding boot camp graduates.
That's just horrible
>>
>>106581766
The problem is that if you use a normal, modern computer, the table is going to be very wrong
>>
>>106582930
Reminder that C is a PDP11 emulator
>>
>>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
>>
>>106581206
Which book is this?
>>
>>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
>>
>>106581206
>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.
>>
File: 1732645939563802.png (44 KB, 1052x1052)
44 KB
44 KB PNG
come home white men
>>
>>106581206
>How brown do you have to be
How many books have you published?
>>
>>106583604
that table is also wrong
>>
>>106583493
>It describes a spec that doesn't exist, so it is wrong by definition
the absolute state of cs undergrads these days...
>>
>>106583876
okay, show me. you won't, because you can't.
>cs undergrads
why are you thinking about zoomers so much?
>>
>>106583604
A char is universally 8 bits though, right?
>>
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
>>
>>106584842
Today, but not historically. Thus, C never defined them as 8 bits
https://en.wikipedia.org/wiki/Byte
>>
>>106581445
Correct
>>
>>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.
>>
>>106582494
>That's just horrible

You must be new here
>>
>>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
>>
>>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.
>>
>>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)
>>
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).
>>
>>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
>>
>>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.
>>
>>106586322
>there is no practical reason to memorize the byte size of a data type
most retarded statement posted on /g/ this month award
>>
>>106586383
>>106586390
your autistic low level hobby project isn't a critical system
>>
>>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
>>
>>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.
>>
>>106586434
you keep repeating the word "critical system" like it's some magic word that will make you not sound unemployed
>>
>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
>>
>>106586454
>Data types in c? Who the fuck needs to know that beyond university students!1!
LMAO
>>
>>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?
>>
>>106581206
This is correct for 16bit MCUs.
>>
>>106586475
What if it uses one's complement?
>>
>>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).
>>
>>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;
>>
>>106581206
>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
>>
>>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
>>
>>106581206
Use case for learning all dat when LLMs exist?
>>
>>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.
>>
>>106581242
This triggers me. The reason I use double for strains and shit in solvers is not because they are big
>>
>>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.
>>
>>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.
>>
>>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.
>>
>>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
>>
>>106586602
Clearly that machine that implementation is for does not, otherwise the rangers would be different.
>>
>>106588431
Is it clear? What if the machine has 2 operating modes with distinct signed integer representation?
>>
>>106587999
The problem is that 'ascii codes' doesn't have anything to do with the range being -128 to 127.
>>
>>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
>>
>>106581206
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.
>>
>>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.
>>
>>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.
>>
>>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.
>>
File: 1743068644133663.png (862 KB, 596x704)
862 KB
862 KB PNG
>>106581206
>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.
>>
>>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.
>>
>>106590735
>c programmers writing c: um actually the type blah blah blah
>c programmers writing make: works on my machine
KEK
>>
>>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
>>
>>106587941
> code size
what is the Thumb 1 and Thumb 2 instruction sets?
>>
You can't make this shit up. It's lifted from an older Indian book C In Depth by Srivastava
>>106587685
>>106581206
>>
>>106591519
Literally stolen from this book with the machine and range qualifiers removed. LMAO
>>
that book is correct. read the C standard, plebs.
>>
File: xfKAin-a_400x400.jpg (23 KB, 400x400)
23 KB
23 KB JPG
>>106581242
>0.000000000000000000000000000001 is very big number, saar
>>
>>106591519
Found it again in another book, Indian author again.
>>
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.
>>
>>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".
>>
>>106593049
*gtfo back to facebook
>>
>>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
>>
>>106593049
i accept your concession
>>
>>106593078
i'm sure the size of an int plays a big role in your hobby project
>>
>>106593094
sneethe
>>
File: anon.png (177 KB, 612x389)
177 KB
177 KB PNG
>>106586322
>
>>
>>106593303
>>106593081
>>106593183
>>
>>106581206
this makes me wonder, is the extra negative value from two's complement representation ever useful? all it does is cause potential errors when flipping the sign. i think that the FP chads got it right, a bit sign is superior in every way, and wasting 1 out of 255 values doesn't matter at all in practice.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.