-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Minor text edits #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor text edits #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many comments :/
|
||
```js | ||
let billion = 1000000000; | ||
``` | ||
|
||
But in real life we usually dislike writing many zeroes. It's easy to mistype. Also we are lazy. We will usually write something like `"1bn"` for a billion or `"7.3bn"` for 7 billions 300 millions. The similar is true for other big numbers. | ||
But in real life we usually avoid writing the full number as it's easy to mistype. Also, we are lazy. We will usually write something like `"1bn"` for a billion or `"7.3bn"` for 7 billion 300 million. The same is true for most large numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that it's easy to type wrong many zeroes, not just full numbers. What's wrong about explicitly saying it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. Maybe the last sentence here should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iliakan "writing many zeroes" is a somewhat awkward phrase, but you are right that it is more explicit than "the full number". In @gwooly edit, the reader must infer that "the full number" refers to the billion variable value, but to me it makes sense. alternate suggestion "we usually avoid writing a long string of zeroes as it's easy to mistype".
@@ -125,7 +125,7 @@ There are following built-in functions for rounding: | |||
: Rounds to the nearest integer: `3.1` becomes `3`, `3.6` becomes `4` and `-1.1` becomes `-1`. | |||
|
|||
`Math.trunc` (not supported by Internet Explorer) | |||
: Removes the decimal part: `3.1` becomes `3`, `-1.1` becomes `-1`. | |||
: Removes anything after the decimal without rounding: `3.1` becomes `3`, `-1.1` becomes `-1`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Removes anything after the decimal" - are you sure about it? Maybe you mean "after the decimal point"?
Are you sure the original text is wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to look this one up, but I have a feeling @iliakan already knew :) The word 'decimal' refers to either any numeral in the decimal system (aka base 10 system) OR any digit following the decimal separator. 'Decimal point' refers to the separator itself. So, yea @gwooly should have said "anything after the decimal point'...
|
||
1. Multiply-and-divide. | ||
|
||
For instance, to round the number to the 2nd digit after the point, we can multiply the number by `100`, call the rounding function and then divide back. | ||
For example, to round the number to the 2nd digit after the decimal, we can multiply the number by `100`, call the rounding function, and then divide back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question: "just decimal", not "decimal point"?
Also, is the comma after "function" really required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above for the decimal point question. as for the comma, this is a long standing point of contention in English grammar. Google "Oxford comma" for more info. I think the main goal is just to remain consistent. I noticed early on that the articles consistently DO NOT use the Oxford comma, so I avoided added them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I did not know about the Oxford comma, now I do know. So funny different languages have different comma rules for precisely the same syntax constructs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is difficult, but I agree if it's not present in the other sections as such, then it is OK to remove to keep consistency. I'll retract the comma but add 'it': and then divide it back.
@@ -159,14 +159,14 @@ There are two ways to do so. | |||
alert( num.toFixed(1) ); // "12.3" | |||
``` | |||
|
|||
The rounding goes to the nearest value, similar to `Math.round`: | |||
This round up or down to the nearest value, similar to `Math.round`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "This rounds"? The original wording is wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "This rounds..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the original wording is wrong, @jmbothe ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the original wording is not wrong, but its awkward to use a verbal noun when a verb would suffice. But from a purely grammatical standpoint, the original wording is acceptable.
|
||
A number is stored in memory in it's binary form, as a sequence of ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form. | ||
A number is stored in memory in it's binary form, a sequence of ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "it's" should be replaced by "its"? Or just "the binary form"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, "it's" should be changed to "its". Removing "as" is appropriate.
|
||
But in real life we often have values in units, like `"100px"` or `"12pt"` in CSS. Also in many countries the currency symbol goes after the amount, so we have `"19€"` and would like to extract a numeric value out of that. | ||
But in real life we often have values in units, like `"100px"` or `"12pt"` in CSS. Also in many countries, the currency symbol goes after the amount, so we have `"19€"`, but would still like to extract a numeric value out of that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "but"? That's "and"...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original and edited content seem equivalent to me. I understand both well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gwooly could you leave the original content here please? :) Looks like it's not wrong =)
|
||
That's what `parseInt` and `parseFloat` are for. | ||
|
||
They "read" a number from a string until they can. In case of an error, the gathered number is returned. Function `parseInt` reads an integer number, `parseFloat` reads any number: | ||
They "read" numbers within a string and unless there's an error (for example, if the first character of a string is not a number), the first valid number is returned. The function `parseInt` returns an integer, whilst `parseFloat` will return a floating-point number: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They read only one "number", not "numbers". The idea is that they aread from the start to the first error and then return what they've got.
Is there a better way to say that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahaha. Yea, this one is difficult to describe. I'll give it a shot, but I'm not sure if it will be adequate:
"They 'read' a string character by character, beginning with index 0. When they encounter the first non-numeral character, they stop reading and return the beginning portion of the string: the parsed number. If the first character is not a number, they return NaN."
That's a good start anyway :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm yes, but parseFloat
accepts the first point .
and stops at the second one:
parseFloat('1.2.3') == '1.2'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhh. good point. I think I might have to recuse myself from this one. The topic is beyond my expertise.
|
||
```js run | ||
alert( parseInt('100px') ); // 100 | ||
alert( parseFloat('12.5em') ); // 12.5 | ||
|
||
alert( parseInt('12.3') ); // 12, only integer part | ||
alert( parseInt('12.3') ); // 12, only the integer is returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean "the integer part" as defined here: https://oeis.org/wiki/Integer_part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with @iliakan
alert( parseFloat('12.3.4') ); // 12.3, the second point stops the reading | ||
``` | ||
|
||
Of course, there are situations when `parseInt/parseFloat` return `NaN`. It happens when no digits could be read: | ||
There are situations when `parseInt/parseFloat` will return `NaN`. It happens when no digits could be read: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "will" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these make sense to me. They seem equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could say 'will return' or 'returns'. Just 'return' reads wrong when read.
@@ -423,12 +423,12 @@ For different numeral systems: | |||
|
|||
For converting values like `12pt` and `100px` to a number: | |||
|
|||
- Use `parseInt/parseFloat` for the "soft" conversion, which reads a number from a string until it can. | |||
- Use `parseInt/parseFloat` for the "soft" conversion, which reads a number from a string until broken by something that is not a number. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...and then return the value they could read before the error?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So: 'Use parseInt/parseFloat
for the "soft" conversion, which reads a number from a string and then returns the value they could read before the error.'
I'll wait to see comments from @jmbothe - if this is not accurate then apologies - don't want to create more work for you! |
@gwooly thank you. Please note that you create work not for me, but for many people across the world. I'm merely trying to make sure that PRs are good. That's very hard if you remember that English is not my native. |
True. This is a great resource so I'd still like to contribute - it might be better if I stick to the grammar/language rather than to modify references to the JS, since it's vital those are 100% accurate (and I am no expert in JS, which is why I also use this guide!). |
No description provided.