Module coil-stdlib

conv

Parsing returns a Result with a short error message. For building text from several values, string::format is usually simpler.

Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.

Import what you use (use path::* is not allowed):

use conv::{int_to_dec, int_to_hex};

Functions#

NameDescription
int_to_decFormats n in decimal; the same as format("%i", n).
int_to_hexFormats n in lowercase hexadecimal without a prefix; a negative n gets a leading -.
int_to_binFormats n in binary without a prefix; a negative n gets a leading -.
parse_int_radixParses an integer written in base radix, which must be 10 or 16.
parse_intParses a decimal integer, such as "42", " -7 " or "+3".
parse_floatParses a decimal float such as "3.5", "-0.25", "1e3" or "42".
↑ ↓ navigate ↵ open