BCAL(1)

NAME
bcal - Perform storage conversions and calculations.

SYNOPSIS
bcal [-c N] [-f FORMAT] [-s bytes] [-d] [-h]
[expression] [N [unit]]

DESCRIPTION
bcal (Byte CALculator) is a command-line utility to help with numerical calculations involving data storage units, addressing, base conversions etc.

Features

  * evaluate arithmetic expressions involving storage units
  * convert to IEC/SI standard data storage units
  * show the address in bytes
  * evaluate arithmetic expression of storage units
  * show address as LBA:OFFSET
  * convert CHS to LBA and vice versa
  * show binary, decimal and hex representation of a number
  * custom sector size, max heads/cylinder and max sectors/track
  * minimal dependencies

bcal follows Ubuntu's standard unit conversion and notation policy. Only 64-bit operating systems are supported. Refer to: https://wiki.ubuntu.com/UnitsPolicy

OPERATIONAL NOTES

1.  Expression: An expression must be within double quotes. Inner spaces are ignored. A storage unit can only be multiplied or divided by positive integers. Only storage units can be used for addition and subtraction.

2.  N [unit]: N can be a decimal or '0x' prefixed hex value. unit can be B/KiB/MiB/GiB/TiB/kB/MB/GB/TB following Ubuntu policy. Default is byte. As all of these tokens are unique, unit is case-insensitive.

3.  Only decimal is recognized in expressions. Decimal and hex numeric representations are recognized for unit conversions. Decimal, hex, binary and octal are recognized for all other operations.

4.  Syntax: Prefix hex inputs with '0x', binary inputs with '0b', octal inputs with '00'.

5.  No negative arguments allowed. Input limits are unsigned long long and double.

6.  Fractional bytes do not exist, because they can't be addressed. bcal shows the floor value of non-integer bytes.

7.  CHS and LBA syntax:
      - LBA: 'lLBA-MAX_HEAD-MAX_SECTOR' [NOTE: LBA starts with 'l' (case ignored)]
      - CHS: 'cC-H-S-MAX_HEAD-MAX_SECTOR' [NOTE: CHS starts with 'c' (case ignored)]
      - Format conversion arguments must be hyphen separated.
      - Any unspecified value, including the one preceding the first '-' to the one following the last '-', is considered '0' (zero).

8.  Default values:
      - sector size: 0x200 (512)
      - max heads per cylinder: 0x10 (16)
      - max sectors per track: 0x3f (63)

OPTIONS

-c=N
    Show decimal, binary and hex representation of N. N must be non-negative.

-f=FORMAT
    Convert CHS to LBA or LBA to CHS. FORMAT is hyphen-separated representation of LBA or CHS. LBA: lLBA-MAX_HEAD-MAX_SECTOR (starts with 'l')
    CHS: cC-H-S-MAX_HEAD-MAX_SECTOR (starts with 'c') Omitted values, (other than MAX_HEAD and MAX_SECTOR) are considered 0. Default MAX_HEAD: 16, default MAX_SECTOR: 63.

-s=bytes
    Sector size in bytes. Default value is 512.

-m  Show minimal output (e.g. decimal bytes).

-d  Enable debug information and logs.

-h  Show program help and exit.

EXAMPLES

1.  Evaluate arithmetic expression of storage units

    $ bcal "(5kb+2mb)/3"
    $ bcal "5 tb / 12"
    $ bcal "2.5mb*3"

2.  Convert storage capacity to other units and get address, LBA.

    $ bcal 20140115 b
    $ bcal 0x1335053 B
    $ bcal 0xaabbcc kb
    $ bcal 0xdef Gib
    Note that the units are case-insensitive.

3.  Convert storage capacity, set sector size to 4096 to calculate LBA.

    $ bcal 0xaabbcc kb -s 4096

4.  Convert LBA to CHS.

    $ bcal -f l500
    $ bcal -f l0x600-18-0x7e
    $ bcal -f l0x300-0x12-0x7e

5.  Convert CHS to LBA.

    $ bcal -f c10-10-10
    $ bcal -f c0x10-0x10-0x10
    $ bcal -f c0x10-10-2-0x12
    $ bcal -f c-10-2-0x12
    $ bcal -f c0x10-10--0x12

6.  Show binary, decimal and hex representations of a number.

    $ bcal -c 20140115
    $ bcal -c 0b1001100110101000001010011
    $ bcal -c 0x1335053

AUTHORS
Arun Prakash Jana <engineerarun@gmail.com>

HOME
https://github.com/jarun/bcal

REPORTING BUGS
https://github.com/jarun/bcal/issues

LICENSE
Copyright © 2016-2017 Arun Prakash Jana <engineerarun@gmail.com>

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.