.TH "BCAL" "1" "Oct 2016" "Version 1.4" "User Commands" .SH NAME bcal \- Perform storage conversions and calculations. .SH SYNOPSIS .B bcal [-c N] [-s bytes] [-h] .br .B " "[N unit] .SH DESCRIPTION .B bcal (Byte CALculator) is a command-line utility to help with numerical calculations involving data storage units, addressing, base conversions etc. .PP .B Features .PP * convert to IEC/SI standard data storage units * show the address in bytes * 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 .PP \fBbcal\fR follows Ubuntu's standard unit conversion and notation policy. Refer to: .I https://wiki.ubuntu.com/UnitsPolicy .SH OPERATIONAL NOTES .PP N unit: N can be decimal or '0x' prefixed hex value. Unit can be B/KiB/MiB/GiB/TiB/kB/MB/GB/TB following Ubuntu policy. As all of these tokens are unique, unit is case-insensitive. .PP Fractional bytes do not exist, because they can't be addressed. \fBbcal\fR shows the floor value of non-integer bytes. .PP Hex and decimal inputs are recognized for all inputs. Binary inputs are supported only with '-c'. This is a provision to convert a binary number to decimal/hex before using it as an input to other operations. No octal support. .PP Syntax: Prefix hex inputs with '0x', binary inputs with '0b'. .PP Default values: - sector size: 0x200 (512) - max heads per cylinder: 0x10 (16) - max sectors per track: 0x3f (63) .PP CHS and LBA inputs for format conversion are hyphen separated. The syntax is: - 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)] Any unspecified value, including the one preceding the first '-' to the one following the last '-', is considered '0'. .PP No negative numbers allowed. Input limits are 'unsigned long long' and 'double'. .SH OPTIONS .TP .BI "-c=" N Show decimal, binary and hex representation of \fIN\fR. Use prefix '0b' for binary and '0x' for hex. \fIN\fR must be non-negative. .TP .BI "-f=" FORMAT Convert CHS to LBA or LBA to CHS. \fIFORMAT\fR is hyphen-separated representation of LBA or CHS. Decimal or '0x' prefixed hex values are accepted. LBA: lLBA-MAX_HEAD-MAX_SECTOR (starts with 'l') .br 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. .TP .BI "-s=" bytes Sector size in bytes. Default value is 512. Decimal and '0x' prefixed hex values accepted. .TP .BI "-h" Show program help and exit. .SH EXAMPLES .PP .IP 1. 4 Convert storage capacity to other units and get address, LBA. .PP .EX .IP .B $ bcal 20140115 b .B $ bcal 0x1335053 B .B $ bcal 0xaabbcc kb .B $ bcal 0xdef Gib Note that the units are case-insensitive. .EE .PP .IP 2. 4 Convert storage capacity, set sector size to 4096 to calculate LBA. .PP .EX .IP .B $ bcal 0xaabbcc kb -s 4096 .EE .PP .IP 3. 4 Convert LBA to CHS. .PP .EX .IP .B $ bcal -f l500 .B $ bcal -f l0x600-18-0x7e .B $ bcal -f l0x300-0x12-0x7e .EE .PP .IP 4. 4 Convert CHS to LBA. .PP .EX .IP .B $ bcal -f c10-10-10 .B $ bcal -f c0x10-0x10-0x10 .B $ bcal -f c0x10-10-2-0x12 .B $ bcal -f c-10-2-0x12 .B $ bcal -f c0x10-10--0x12 .EE .PP .IP 5. 4 Show binary, decimal and hex representations of a number. .PP .EX .IP .B $ bcal -c 20140115 .B $ bcal -c 0b1001100110101000001010011 .B $ bcal -c 0x1335053 .SH AUTHORS Arun Prakash Jana .SH HOME .I https://github.com/jarun/bcal .SH REPORTING BUGS .I https://github.com/jarun/bcal/issues .SH LICENSE Copyright \(co 2016 Arun Prakash Jana .PP License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.