This commit is contained in:
Miloslav Ciz 2023-07-29 17:21:21 +02:00
parent 89693a5451
commit 02f5ac44fc
3 changed files with 5 additions and 5 deletions

View file

@ -6,7 +6,7 @@ He loves all living beings, even those whose attributes he hates or who hate him
Drummyfish has a personal website at [www.tastyfish.cz](https://www.tastyfish.cz), and a gopherhole at [self.tastyfish.cz](gopher://self.tastyfish.cz).
Photos of drummyfish: [young](https://cloud.disroot.org/apps/files_sharing/publicpreview/4E36WS5ZN42pasg?file=/me/156%20-%20sQNYr3g.png&fileId=122364667&x=1280&y=800&a=true), [older](https://upload.wikimedia.org/wikipedia/commons/2/26/Drummyfish_profile_photo.png) (after being confronted with real life) and [naked](https://commons.wikimedia.org/wiki/File:Naked_white_male_32yo.png) (warning: fat and ugly, see also [dick reveal](dick_reveal.md)).
Photos of drummyfish: [young](https://cloud.disroot.org/apps/files_sharing/publicpreview/4E36WS5ZN42pasg?file=/me/156%20-%20sQNYr3g.png&fileId=122364667&x=1280&y=800&a=true), [older](https://upload.wikimedia.org/wikipedia/commons/2/26/Drummyfish_profile_photo.png) (after being confronted with real life) and [naked](https://commons.wikimedia.org/wiki/File:Drummyfish_naked_all_sides_beard.png).
Drummyfish's real name is Miloslav Číž, he was born on 24.08.1990 and lives in Moravia, Czech Republic, [Earth](earth.md) (he rejects the concept of a country/[nationalism](nationalism.md), the info here serves purely to specify a location). He is a more or less straight [male](man.md) of the [white](white.md) [race](race.md). He started programming at high school in [Pascal](pascal.md), then he went on to study [compsci](compsci.md) (later focused on [computer graphics](graphics.md)) in a Brno University of Technology and got a [master's degree](msc.md), however he subsequently refused to find a job in the industry, partly because of his views (manifested by [LRS](lrs.md)) and partly because of mental health issues (depressions/anxiety/avoidant personality disorder). He rather chose to stay closer to the working class and do less harmful [slavery](job.md) such as cleaning and physical [spam](spam.md) distribution, and continues [hacking](hacking.md) on his programming (and other) projects in his spare time in order to be able to do it with absolute freedom.

View file

@ -17,7 +17,7 @@ So, **we can just use an integer data type as a fixed point data type**, there i
We may look at it this way: we still use integers but we use them to count smaller fractions than 1. For example in a 3D game where our basic spatial unit is 1 meter our variables may rather contain the number of centimeters (however in practice we should use powers of two, so rather 1/128ths of a meter). In the example in previous paragraph we count 1/4ths (we say our **scaling factor** is 1/4), so actually the number represented as `00000100` is what in floating point we'd write as `1.0` (`00000100` is 4 and 4 * 1/4 = 1), while `00000001` means `0.25`.
This has just one consequence: **we have to [normalize](normalize.md) results of multiplication and division** (addition and subtraction work just as with integers, we can normally use the `+` and `-` operators). I.e. when multiplying, we have to divide the result by the inverse of the fractions we're counting, i.e. by 4 in our case (1/(1/4) = 4). Similarly when dividing, we need to MULTIPLY the result by this number. This is because we are using fractions as our units and when we multiply two numbers in those units, the units multiply as well, i.e. in our case multiplying two numbers that count 1/4ths give a result that counts 1/16ths, we need to divide this by 4 to get the number of 1/4ths back again (this works the same as e.g. units in physics, multiplying number of meters by number of meters gives meters squared.) For example the following integer multiplication:
This has just one consequence: **we have to [normalize](normalization.md) results of multiplication and division** (addition and subtraction work just as with integers, we can normally use the `+` and `-` operators). I.e. when multiplying, we have to divide the result by the inverse of the fractions we're counting, i.e. by 4 in our case (1/(1/4) = 4). Similarly when dividing, we need to MULTIPLY the result by this number. This is because we are using fractions as our units and when we multiply two numbers in those units, the units multiply as well, i.e. in our case multiplying two numbers that count 1/4ths give a result that counts 1/16ths, we need to divide this by 4 to get the number of 1/4ths back again (this works the same as e.g. units in physics, multiplying number of meters by number of meters gives meters squared). For example the following integer multiplication:
`00001000` * `00000010` = `00010000` (8 * 2 = 16)
@ -29,7 +29,7 @@ SIDE NOTE: in practice you may see division replaced by the shift operator (inst
With this normalization we also have to **think about how to bracket expressions to prevent rounding errors and [overflows](overflow.md)**, for example instead of `(x / y) * 4` we may want to write `(x * 4) / y`; imagine e.g. *x* being `00000010` (0.5) and *y* being `00000100` (1.0), the former would result in 0 (incorrect, rounding error) while the latter correctly results in 0.5. The bracketing depends on what values you expect to be in the variables so it can't really be done automatically by a compiler or library (well, it might probably be somehow handled at [runtime](runtime.md), but of course, that will be slower). There are also ways to prevent overflows e.g. with clever [bit hacks](bit_hack.md).
The normalization is basically the only thing you have to think about, apart from this everything works as with integers. Remember that **this all also works with negative number in [two's complement](twos_complement.md)**, so you can use a signed integer type without any extra trouble.
The normalization and bracketing are basically the only things you have to think about, apart from this everything works as with integers. Remember that **this all also works with negative number in [two's complement](twos_complement.md)**, so you can use a signed integer type without any extra trouble.
Remember to **always use a power of two scaling factor** -- this is crucial for performance. I.e. you want to count 1/2th, 1/4th, 1/8ths etc., but NOT 1/10ths, as might be tempting. Why are power of two good here? Because computers work in binary and so the normalization operations with powers of two (division and multiplication by the scaling factor) can easily be optimized by the compiler to a mere [bit shift](bit_shift.md), an operation much faster than multiplication or division.
@ -55,7 +55,7 @@ printf("%f\n",a);
Equivalent code with fixed point may look as follows:
```
#define UNIT 1024 // our "1.0" value
#define UNIT 1024 // our "1.0" value
int
a = 21 * UNIT,

View file

@ -4,7 +4,7 @@
Terry A. Davis, aka the *divine intellect*, born 1969 in Wisconsin, was a genius+[schizophrenic](schizo.md) [programmer](programming.md) that singlehandedly created [TempleOS](temple_os.md) in his own [programming language](programming_language.md) called [HolyC](holyc.md), and greatly entertained and enlightened an audience of followers until his tragic untimely death. For his programming skills and quality videos he became a legend and a [meme](meme.md) in the tech circles, especially on [4chan](4chan.org) which additionally valued his [autistic](autism.md) and [politically incorrect](political_correctness.md) behavior.
He was convinced he could talk to God and that God commanded him to make an operating system with certain parameters such as 640x480 resolution, also known as the God resolution. According to himself he was gifted a *divine intellect* and was, in his own words, the "best programmer that ever lived". Terry was making [YouTube](youtube.md) talking/programming videos in which God was an often discussed topic, alongside valuable programming advice and a bit of good old [racism](racism.md). He was also convinced that the government was after him and often delved into the conspiracies against him, famously proclaiming that **"CIA [niggers](nigger.md) glow in the dark"** ("glowing in dark" subsequently caught on as a phrase used for anything [suspicious](sus.md)). He was in mental hospital several times and later became homeless, but continued to post videos from his van. An entertaining fact is also that he fell in love with a famous female physics YouTuber Dianna Cowern which he stalked online. In 2018 he was killed by a train (officially a [suicide](suicide.md) but word has it CIA was involved) but he left behind tons of videos full of endless entertainment, and sometimes even genuine [wisdom](wisdom.md).
He was convinced he could talk to [God](god.md) and that God commanded him to make an operating system with certain parameters such as 640x480 resolution, also known as the God resolution. According to himself he was gifted a *divine intellect* and was, in his own words, the "best programmer that ever lived". Terry was making [YouTube](youtube.md) talking/programming videos in which God was an often discussed topic, alongside valuable programming advice and a bit of good old [racism](racism.md). He was also convinced that the government was after him and often delved into the conspiracies against him, famously proclaiming that **"CIA [niggers](nigger.md) glow in the dark"** ("glowing in dark" subsequently caught on as a phrase used for anything [suspicious](sus.md)). He was in mental hospital several times and later became homeless, but continued to post videos from his van. An entertaining fact is also that he fell in love with a famous female physics YouTuber Dianna Cowern which he stalked online. In 2018 he was killed by a train (officially a [suicide](suicide.md) but word has it CIA was involved) but he left behind tons of videos full of endless entertainment, and sometimes even genuine [wisdom](wisdom.md).
Terry, just as [us](lrs.md), greatly valued [simplicity](minimalism.md) and [fun](fun.md) in programming, he was a low-level programmer and saw that technology went to [shit](shit.md) and wanted to create something in the oldschool style, and he expressed his will to dedicate his creation to the [public domain](public_domain.md). This is of course extremely based and appreciated by [us](lrs.md) (though the actual public domain dedication wasn't executed according to our recommendations).