Not sure I understand what you mean;
n / a / b / c
is simply n / (a * b * c)
; in this special case, n / 1024^3
.Yep, you answered the question exactly. Thanks! I don't fully understand it, because I suck at maths, but I have a basic understanding of it.
Code: Select all
free -b | awk '$1 == "Mem:" {printf("%.2f GiB\n", $3 / (1024 ^ 3))}'
Code: Select all
free -b | awk '$1 == "Mem:" {printf("%.2f GiB\n", $3 / 1024 / 1024 / 1024)}'
I had absolutely no idea that was a thing. I've never had any errors — that is — I've never had an incorrect number when dividing, as far as I know, but I only tend to use N.NNN at most, so I'm guessing this is only really a problem with numbers like N.NNNNNN, where such specificity is needed; is that right? What confuses me, now, is that you're still dividing by the (N ^ N) value, so don't you still wind up with the chance for an error?
If you have a YouTube channel talking about all this stuff, I'd happily watch it! Thanks for the information.
Haha That looks similar to some "random number generator" code I once saw.
I'm guessing it was something along these lines:FreedomTruth wrote: ⤴Thu Jul 29, 2021 11:04 am Haha That looks similar to some "random number generator" code I once saw.
Code: Select all
printf '%04d\n' $((RANDOM % 9999))