Skip to content

Commit 2228695

Browse files
Copilotjgphilpott
andcommitted
Use power notation (**) instead of repeated multiplication
- Changed 1024*1024*1024 to 1024**3 for better readability - Updated polyconvert.coffee constants to use power notation - Updated README.md examples to use power notation - All 2220 tests passing with correct conversions Co-authored-by: jgphilpott <[email protected]>
1 parent b8fb9b4 commit 2228695

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ polyconvert.data.bit = {
144144
bit: f(x) = x,
145145
byte: f(x) = x/8,
146146
kilobyte: f(x) = x/(8*1024),
147-
megabyte: f(x) = x/(8*1024*1024),
148-
gigabyte: f(x) = x/(8*1024*1024*1024),
149-
terabyte: f(x) = x/(8*1024*1024*1024*1024),
150-
petabyte: f(x) = x/(8*1024*1024*1024*1024*1024),
151-
exabyte: f(x) = x/(8*1024*1024*1024*1024*1024*1024),
152-
zettabyte: f(x) = x/(8*1024*1024*1024*1024*1024*1024*1024),
153-
yottabyte: f(x) = x/(8*1024*1024*1024*1024*1024*1024*1024*1024)
147+
megabyte: f(x) = x/(8*1024**2),
148+
gigabyte: f(x) = x/(8*1024**3),
149+
terabyte: f(x) = x/(8*1024**4),
150+
petabyte: f(x) = x/(8*1024**5),
151+
exabyte: f(x) = x/(8*1024**6),
152+
zettabyte: f(x) = x/(8*1024**7),
153+
yottabyte: f(x) = x/(8*1024**8)
154154

155155
}
156156
```

polyconvert.coffee

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,13 @@ convertArea.hectare.hectare = ha$ha = (ha) -> ha # Hectare to Hectare
389389

390390
# Binary (IEC) unit constants for performance
391391
BYTES_PER_KIBIBYTE = 1024
392-
BYTES_PER_MEBIBYTE = 1024 * 1024
393-
BYTES_PER_GIBIBYTE = 1024 * 1024 * 1024
394-
BYTES_PER_TEBIBYTE = 1024 * 1024 * 1024 * 1024
395-
BYTES_PER_PEBIBYTE = 1024 * 1024 * 1024 * 1024 * 1024
396-
BYTES_PER_EXBIBYTE = 1024 * 1024 * 1024 * 1024 * 1024 * 1024
397-
BYTES_PER_ZEBIBYTE = 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024
398-
BYTES_PER_YOBIBYTE = 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024
392+
BYTES_PER_MEBIBYTE = 1024 ** 2
393+
BYTES_PER_GIBIBYTE = 1024 ** 3
394+
BYTES_PER_TEBIBYTE = 1024 ** 4
395+
BYTES_PER_PEBIBYTE = 1024 ** 5
396+
BYTES_PER_EXBIBYTE = 1024 ** 6
397+
BYTES_PER_ZEBIBYTE = 1024 ** 7
398+
BYTES_PER_YOBIBYTE = 1024 ** 8
399399

400400
convertData =
401401

polyconvert.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)