When you need really large numbers, use the BigInt and BigDecimal types:
var a = BigInt(1_234_567_890_987_654_321L)
var b = BigDecimal(123_456.789)
It is not apparent to reader why these are "really large numbers", and why they should use them instead of directly writing 1_234_567_890_987_654_321L and 123_456.789.
I suggest this be reworded to say technically correct something like
When you need to use numbers so large they exceed the range of Long, or that require a higher number of decimal digits than support by Double, use the BigInt and BigDecimal types
And instead of passing primitive values to the constructors, use the string constructors that demonstrate the "really large numbers", e.g.
BigInt("1234567890000000000000000")
Then, instead of just saying
A great thing about BigInt and BigDecimal is that they support all the operators you’re used to using with numeric types:
point out that for example BigInt does not produce numeric overflow:
1234567890 * 1234567890 // silently overflowing to become 304084036
BigInt(1234567890) * BigInt(1234567890) // correct: 1524157875019052100
They are introduced here: https://docs.scala-lang.org/scala3/book/taste-vars-data-types.html and here: https://docs.scala-lang.org/scala3/book/first-look-at-types.html
The description is vague and not helpful:
It is not apparent to reader why these are "really large numbers", and why they should use them instead of directly writing
1_234_567_890_987_654_321L
and123_456.789
.I suggest this be reworded to say technically correct something like
And instead of passing primitive values to the constructors, use the string constructors that demonstrate the "really large numbers", e.g.
Then, instead of just saying
point out that for example
BigInt
does not produce numeric overflow: