Skip to main content

Module typst

Module typst 

Source
Expand description

ToTypst implementations for primitive integers and primitive floats, converting them to Typst math-mode fragments.

ยงfmt_typst

use malachite_base::strings::typst::ToTypst;

assert_eq!(0u8.to_typst_string(), "0");
assert_eq!(123u32.to_typst_string(), "123");
assert_eq!((-45i16).to_typst_string(), "-45");
assert_eq!(i64::MIN.to_typst_string(), "-9223372036854775808");
valuefragment
0u80
123u32123
-45i16-45
i64::MIN-9223372036854775808
use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::basic::traits::NegativeInfinity;
use malachite_base::strings::typst::ToTypst;

assert_eq!(f64::NAN.to_typst_string(), r#""NaN""#);
assert_eq!(f64::INFINITY.to_typst_string(), "infinity");
assert_eq!(f64::NEGATIVE_INFINITY.to_typst_string(), "-infinity");
assert_eq!(0.0f64.to_typst_string(), "0.0");
assert_eq!((-0.0f64).to_typst_string(), "-0.0");

assert_eq!(1.0f64.to_typst_string(), "1.0");
assert_eq!(0.00123f64.to_typst_string(), "0.00123");
assert_eq!(1.0e16f64.to_typst_string(), "1.0 times 10^(16)");
assert_eq!(
    f32::MIN_POSITIVE_SUBNORMAL.to_typst_string(),
    "1.0 times 10^(-45)"
);
valuefragment
f64::NAN"NaN"
f64::INFINITYinfinity
f64::NEGATIVE_INFINITY-infinity
0.00.0
-0.0-0.0
1.01.0
0.001230.00123
1.0e161.0 times 10^(16)
f32::MIN_POSITIVE_SUBNORMAL1.0 times 10^(-45)