Skip to content

Custom Units

CalcpadCE ships with the SI base and derived units built in, but the unit system itself is open: any new dimension can be declared with #def and used like a native unit in the rest of the worksheet.

The two pages in this group illustrate the pattern with everyday examples. Currency Units defines USD, EUR and a handful of other currencies along with their cross-rates so that monetary expressions auto-convert and round correctly, while Information Units sets up bit, byte, KiB, MiB and friends with their binary prefixes, ready for bandwidth and storage calculations.

Each page is self-contained and can be #included into any worksheet that needs the same units, providing a starting template for your own custom unit families.

Currency Units

Defines USD, EUR and other currencies as custom units with cross-rates, so monetary expressions auto-convert and round consistently across the worksheet.

Code:
'<p><b>Definition</b></p>
.EUR = 1
.USD = 0.92EUR
.BGN = 0.511291881196218EUR
'<p><b>Conversion</b></p>
10BGN|USD
20EUR|BGN
30EUR|USD
'<p><b>Usage</b></p>
'Unit price - 'p = 15USD/m
'Order length -'L = 100m
'Total price in USD -'P = p*L|USD
'Total price in EUR -'P|EUR
Rendered Output:

Definition

EUR = 1

USD = 0.92 EUR

BGN = 0.511 EUR

Conversion

10 BGN = 5.56 USD

20 EUR = 39.12 BGN

30 EUR = 32.61 USD

Usage

Unit price - p = 15 USDm

Order length - L = 100 m

Total price in USD - P = p · L = 15 USD ∕ m · 100 m = 1500 USD

Total price in EUR - P = 1380 EUR

Information Units

Defines bit, byte and the binary prefixes (KiB, MiB, GiB, TiB) as custom units, ready for bandwidth and storage calculations.

Code:
'<p><b>Definition</b></p>
.bit = 1
.byte = 8bit
.KB = 1000byte','.KiB = 1024byte
.MB = 1000KB','.MiB = 1024KiB
.TB = 1000MB','.TiB = 1024MiB
.PB = 1000TB','.PiB = 1024TiB
.EB = 1000PB','.EiB = 1024PiB
.ZB = 1000EB','.ZiB = 1024EiB
.YB = 1000ZB','.YiB = 1024ZiB
'<p><b>Conversion</b></p>
MiB|byte
TiB|byte
'<p><b>Usage</b></p>
v = 10000000byte/s
v|TiB/h
Rendered Output:

Definition

bit = 1

byte = 8 bit

KB = 1000 byte , KiB = 1024 byte

MB = 1000 KB , MiB = 1024 KiB

TB = 1000 MB , TiB = 1024 MiB

PB = 1000 TB , PiB = 1024 TiB

EB = 1000 PB , EiB = 1024 PiB

ZB = 1000 EB , ZiB = 1024 EiB

YB = 1000 ZB , YiB = 1024 ZiB

Conversion

MiB = 1048576 byte

TiB = 1073741824 byte

Usage

v = 10000000 bytes

v = 33.53 TiB ∕ h

Spotted an error? Edit these examples.