After climbing the ternary I/O mountain, and crafting functions that both input and output base 3 values, the next step is obvious: Combine both functions into a single program. The step after that is less obvious: Change the code so that any base can be used to process input or generate output.
Continue reading
Category Archives: Lesson
Eating Ternary Input
I’m happy I chose to write the function that consumes a ternary value last, shown in last week’s Lesson. The process turns out to be not that big of a deal, though trepidations scurried around me as I wrote the code.
Continue reading
The ternary_out() Function
I believe my approach was okay for generating ternary (base 3) numbers, but for some reason I couldn’t get my algorithm to work. From last week’s Lesson, here’s what I tried:
Continue reading
Dreaming of the ternary_out() Function
To generate a string of digits representing a value in a specific power base, such as base 3 (ternary), you need a power table. Using this power table, you can translate any positive integer into a string representation of the number in the given base. Sounds complex. Is complex.
Continue reading
Powers of Three
When the math nerds refer to a counting system, they use the word base. “We count in base 10,” they proclaim, adding, “Decimal” to sound important. Surely, these are the miracles of mathematics.
Continue reading
Degrees to Radians to Degrees
The C language uses radians instead of degrees when calculating angles. Humans should use radians as well, as they’re logical and easy to work with (radians, not humans). What surprises me, however, is that the C library lacks a defined constant for making the degree-radian conversion.
Continue reading
Creating a File “in the Raw” – with Permissions
Way back in April, I concluded my series on the “raw” file functions with a program that created a new file — but one that had no permissions. Thanks to input from readers and research into file-permission functions, I have a solution to the puzzle.
Continue reading
Changing a File’s Permissions
In Unix-like operating systems, the chmod shell command alters a file’s permissions. From the C library, the chmod() function does the same thing.
Continue reading
Examining File Type and Permissions
The value returned as a file’s inode mode is difficult to interpret, as covered in last week’s Lesson. That is, unless you use the macros and defined constants available in the sys/stat.h header file.
Continue reading
Finding File Permissions
All files carry with them something called an inode, which contains file data beyond the file’s name and its contents. The inode references the file’s size, its timestamps, and the file type or mode. It’s this file mode that determines how the file is used, which users can access the file, and what can be done with the file when accessed.
Continue reading