Skip to content

Convert data category from SI decimal (1000) to IEC binary (1024) units#4

Merged
jgphilpott merged 9 commits into
mainfrom
copilot/update-data-category-units
Dec 25, 2025
Merged

Convert data category from SI decimal (1000) to IEC binary (1024) units#4
jgphilpott merged 9 commits into
mainfrom
copilot/update-data-category-units

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 22, 2025

Plan: Update Data Category to Binary (IEC) Units

  • Understand the current implementation (SI/decimal units: KB = 1000 bytes)
  • Update conversion formulas in polyconvert.coffee to use binary units (KiB = 1024 bytes)
    • Update bit conversions to use 1024-based multipliers
    • Update byte conversions to use 1024-based multipliers
    • Update kilobyte to kibibyte conversions
    • Update megabyte to mebibyte conversions
    • Update gigabyte to gibibyte conversions
    • Update terabyte to tebibyte conversions
    • Update petabyte to pebibyte conversions
    • Update exabyte to exbibyte conversions
    • Update zettabyte to zebibyte conversions
    • Update yottabyte to yobibyte conversions
  • Update validation tests to expect binary values
  • Update README.md documentation to reflect binary units
  • Compile CoffeeScript to JavaScript
  • Run tests to verify changes (all 2220 tests passing)
  • Optimize with pre-computed constants for better performance
  • Final code review and address feedback
  • Update README examples to showcase binary conversions
  • Use power notation for better readability
  • Complete
Original prompt

Can we update the data category to use binary (IEC) units instead of decimal (SI) units?


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 22, 2025 09:57
- Changed all data unit conversions from SI (decimal, base 1000) to IEC (binary, base 1024)
- Updated conversion formulas in polyconvert.coffee to use Math.pow(1024, n) instead of 1e+n
- Updated validation tests to expect binary values (1024, 1048576, etc.)
- Updated README documentation to clarify binary units are used
- All tests passing (2220 tests)

Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
- Added binary unit constants (BYTES_PER_KIBIBYTE, etc.) for performance
- Replaced Math.pow(1024, n) calls with pre-computed constants
- Improves performance by avoiding repeated function calls
- All 2220 tests still passing

Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
- Changed exponentiation notation from ^ to explicit multiplication
- Makes the formula more clear and easier to understand
- All tests still passing

Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
Copilot AI changed the title [WIP] Update data category to use binary units Convert data category from SI decimal (1000) to IEC binary (1024) units Dec 22, 2025
Copilot AI requested a review from jgphilpott December 22, 2025 10:04
@jgphilpott
Copy link
Copy Markdown
Owner

@copilot what about this section of the README dosn't it need to be updates as well?


So, to use these functions, reference them through the polyconvert object and pass in the value you want to convert, like this:

polyconvert.data.bit.byte(100) // Returns 12.5 meaning that 100 bits equals 12.5 bytes

To reverse the conversion simply switch the order of the unit keys, like this:

polyconvert.data.byte.bit(12.5) // Returns 100 meaning that 12.5 bytes equals 100 bits

- Changed examples from bit/byte to kilobyte/byte conversions
- Better demonstrates the IEC binary units (1 KiB = 1024 bytes)
- Examples now showcase the main change in this PR

Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 23, 2025

@copilot what about this section of the README dosn't it need to be updates as well?


...

You're absolutely right! Updated the examples to showcase the binary unit conversions (1 KiB = 1024 bytes) instead of bit/byte conversions. This better demonstrates the key change in this PR. Commit: 87f5378

@jgphilpott
Copy link
Copy Markdown
Owner

@copilot in both the README and the polyconvert.coffee files, instead of doing 1024*1024*1024 ... can we use power notation like 1024**2 or 1024**3. This is cleaner and easier to read.

- 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 <4128208+jgphilpott@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 25, 2025

@copilot in both the README and the polyconvert.coffee files, instead of doing 1024*1024*1024 ... can we use power notation like 1024**2 or 1024**3. This is cleaner and easier to read.

Updated both files to use power notation (**). Changed all instances of repeated multiplication (e.g., 1024*1024*1024) to cleaner power notation (e.g., 1024**3). All tests passing. Commit: 2228695

@jgphilpott jgphilpott marked this pull request as ready for review December 25, 2025 05:01
@jgphilpott jgphilpott merged commit 34939ac into main Dec 25, 2025
1 check passed
@jgphilpott jgphilpott deleted the copilot/update-data-category-units branch December 25, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants