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#
| Name | Description |
|---|---|
int_to_dec | Formats n in decimal; the same as format("%i", n). |
int_to_hex | Formats n in lowercase hexadecimal without a prefix; a negative n gets a leading -. |
int_to_bin | Formats n in binary without a prefix; a negative n gets a leading -. |
parse_int_radix | Parses an integer written in base radix, which must be 10 or 16. |
parse_int | Parses a decimal integer, such as "42", " -7 " or "+3". |
parse_float | Parses a decimal float such as "3.5", "-0.25", "1e3" or "42". |