1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Copyright 2025 Owain Davies
SPDX-License-Identifier: Apache-2.0 OR MIT
*/
use crate::;
use fmt;
/// Format an `Arbi` integer in lowercase hexadecimal (base-16).
///
/// # Examples
/// ```
/// use arbi::Arbi;
///
/// let mut a = Arbi::from(0xC0FFEE);
/// assert_eq!(format!("{a:x}"), "c0ffee");
/// assert_eq!(format!("{a:#x}"), "0xc0ffee");
/// a.negate_mut();
/// assert_eq!(format!("{a:x}"), "-c0ffee");
/// assert_eq!(format!("{a:#x}"), "-0xc0ffee");
///
/// let zero = Arbi::zero();
/// assert_eq!(format!("{zero:x}"), "0");
/// assert_eq!(format!("{zero:#x}"), "0x0");
/// ```
/// Format an `Arbi` integer in uppercase hexadecimal (base-16).
///
/// # Examples
/// ```
/// use arbi::Arbi;
///
/// let mut a = Arbi::from(0xC0FFEE);
/// assert_eq!(format!("{:X}", a), "C0FFEE");
/// assert_eq!(format!("{:#X}", a), "0xC0FFEE");
/// a.negate_mut();
/// assert_eq!(format!("{:X}", a), "-C0FFEE");
/// assert_eq!(format!("{:#X}", a), "-0xC0FFEE");
///
/// let zero = Arbi::zero();
/// assert_eq!(format!("{zero:X}"), "0");
/// assert_eq!(format!("{zero:#X}"), "0x0");
/// ```