Skip to content

Instantly share code, notes, and snippets.

@kentcb
Created February 3, 2021 06:59
Show Gist options
  • Save kentcb/6e713678b350fbeca9cc339597e73a12 to your computer and use it in GitHub Desktop.
Save kentcb/6e713678b350fbeca9cc339597e73a12 to your computer and use it in GitHub Desktop.
void main() {
final units = InformationUnit.values;
for (var i = 0; i < units.length; ++i) {
final unit = units[i];
final bits = unit.numberOfBitsComprisingUnit;
print('BigInt.parse(\'$bits\'): $unit,');
if (i > 0) {
print('BigInt.parse(\'${bits + BigInt.one}\'): $unit,');
}
if (i > 1 && i < (units.length - 1)) {
print('BigInt.parse(\'${units[i + 1].numberOfBitsComprisingUnit - BigInt.one}\'): $unit,');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment