Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 371839b

Browse files
committed
Document formatting specifiers
1 parent 11889f2 commit 371839b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/libm-cdylib/src/test_utils.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ pub(crate) fn format_output(
122122
/// as well as the printf format specifier used to print values of that type.
123123
pub(crate) fn ctype_and_printf_format_specifier(x: &str) -> (&str, &str) {
124124
match x {
125+
// Note: fprintf has no format specifier for floats, `%f`, converts
126+
// floats into a double, and prints that.
127+
//
128+
// For the linking tests, precision doesn't really matter. The only
129+
// thing that's tested is whether our implementation was properly called
130+
// or not. This is done by making our functions return an incorrect
131+
// magic value, different from the correct result. So as long as this is
132+
// precise enough for us to be able to parse `42.0` from stdout as
133+
// 42_f32/f64, everything works.
125134
"f32" => ("float", "%f"),
126135
"f64" => ("double", "%f"),
127136
"i32" => ("int32_t", "%d"),

0 commit comments

Comments
 (0)