Merge pull request #139 from fangliu-tju/main
some typos and a modification for association of + and * in calculator.qmd
This commit is contained in:
commit
36895faafe
@ -207,7 +207,7 @@ The authors note in a supplement to their paper that over 15,700 species and sub
|
||||
(3.02 * 10^15 + 1.34*10^15) * 100 / 22
|
||||
```
|
||||
|
||||
The answer is in *scientific notation$ and reads as $1.89\dots \cdot 10^16$.
|
||||
The answer is in *scientific notation* and reads as $1.98\ldots \cdot 10^{16}$.
|
||||
Shifting the decimal point, this gives a value rounded to $20\cdot 10^{15}$ ants.
|
||||
|
||||
The authors used a value for the *dry weight* of an average (and representative) single ant. What was that value? (Which they indicate is perhaps unreliable,
|
||||
@ -244,7 +244,7 @@ With the Google Calculator, typing `1 + 2 x 3 =` will give the value $7$, but *i
|
||||
In `Julia`, the entire expression is typed in before being evaluated, so the usual conventions of mathematics related to the order of operations may be used. These are colloquially summarized by the acronym [PEMDAS](http://en.wikipedia.org/wiki/Order_of_operations).
|
||||
|
||||
|
||||
> **PEMDAS**. This acronym stands for Parentheses, Exponents, Multiplication, Division, Addition, Subtraction. The order indicates which operation has higher precedence, or should happen first. This isn't exactly the case, as "M" and "D" have the same precedence, as do "A" and "S". In the case of two operations with equal precedence, *associativity* is used to decide which to do. For the operations `+`, `-`, `*`, `/` the associativity is left to right, as in the left one is done first, then the right. However, `^` has right associativity, so `4^3^2` is `4^(3^2)` and not `(4^3)^2`. (Be warned that some calculators - and spread sheets, such as Excel - will treat this expression with left associativity.)
|
||||
> **PEMDAS**. This acronym stands for Parentheses, Exponents, Multiplication, Division, Addition, Subtraction. The order indicates which operation has higher precedence, or should happen first. This isn't exactly the case, as "M" and "D" have the same precedence, as do "A" and "S". In the case of two operations with equal precedence, *associativity* is used to decide which to do. For the operations `-`, `/` the associativity is left to right, as in the left one is done first, then the right. However, `^` has right associativity, so `4^3^2` is `4^(3^2)` and not `(4^3)^2` (Be warned that some calculators - and spread sheets, such as Excel - will treat this expression with left associativity). But, `+` and `*` don't have associativity, so `1+2+3` can be `(1+2)+3` or `1+(2+3)`.
|
||||
|
||||
|
||||
|
||||
@ -598,13 +598,13 @@ The user is expected to have a sense that they need to be careful when their val
|
||||
::: {.callout-note}
|
||||
## Bit-level details
|
||||
|
||||
We can see in the following, using using the smaller 8-bit type, what goes on internally with successive powers of `2`: the bit pattern is found by shifting the previous one over to the left, consistent with what happens at the bit level when multiplying by `2`:
|
||||
We can see in the following, using the smaller 8-bit type, what goes on internally with successive powers of `2`: the bit pattern is found by shifting the previous one over to the left, consistent with what happens at the bit level when multiplying by `2`:
|
||||
|
||||
```
|
||||
[bitstring(Int8(2)^i) for i in 1:8]
|
||||
```
|
||||
|
||||
The last line is similar to what happens to `2^64` which is also `0`, as seen. The second to last line requires some understanding of how integers are represented internally. Of the 8 bits, the last 7 represent which powers of `2` (`2^6`, `2^5`, ..., `2^1`, `2^0`) are included. The first `1` represents `-2^7`. So all zeros, as we see `2^8` is, means `0`, but `"10000000"` means `-2^7`. The largest *positive* number would be represented as `"01111111"` or ``2^6 + 2^5 + \cdots + 2^1 + 2^0 = 2^7 - 1``. These values can be seen using `typemin` and `typemax`:
|
||||
The last line is similar to what happens to `2^64` which is also `0`, as seen. The second to last line requires some understanding of how integers are represented internally. Of the 8 bits, the last 7 represent which powers of `2` (`2^6`, `2^5`, ..., `2^1`, `2^0`) are included. The first `1` represents `-2^7`. So all zeros, as we see `2^8` is, means `0`, but `"10000000"` means `-2^7`. The largest *positive* number would be represented as `"01111111"` or $2^6 + 2^5 + \cdots + 2^1 + 2^0 = 2^7 - 1$. These values can be seen using `typemin` and `typemax`:
|
||||
|
||||
```{julia}
|
||||
typemin(Int8), typemax(Int8)
|
||||
@ -1170,7 +1170,7 @@ choices = [
|
||||
"`10e21`",
|
||||
"`1e22`",
|
||||
"`10_000_000_000_000_000_000_000`"]
|
||||
explanation = "With an *integer* base, `10^21` overflows. For typical integers, only `10^18` is defined as expected. Once `10^19` is entered the mathematical value is larger the the `typemax` for `Int64` and so the value *wraps* around. The number written out with underscores to separate groups of 0s is parsed as an integer with 128 bits, not 64."
|
||||
explanation = "With an *integer* base, `10^21` overflows. For typical integers, only `10^18` is defined as expected. Once `10^19` is entered the mathematical value is larger than the `typemax` for `Int64` and so the value *wraps* around. The number written out with underscores to separate groups of 0s is parsed as an integer with 128 bits, not 64."
|
||||
buttonq(choices, 1; explanation=explanation)
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user