# Function ryu::raw::format64

source · [−]

    pub unsafe fn format64(f: f64, result: *mut u8) -> usize

Expand description

Print f64 to the given buffer and return number of bytes written.

At most 24 bytes will be written.

### Special cases

This function does not check for NaN or infinity. If the input number is not a finite float, the printed representation will be some correctly formatted but unspecified numerical value.

Please check `is_finite` yourself before calling this function, or check `is_nan` and `is_infinite` and handle those cases yourself.

### Safety

The `result` pointer argument must point to sufficiently many writable bytes to hold Ryū’s representation of `f`.

### Example

    use std::{mem::MaybeUninit, slice, str};

    let f = 1.234f64;

    unsafe {
        let mut buffer = [MaybeUninit::<u8>::uninit(); 24];
        let len = ryu::raw::format64(f, buffer.as_mut_ptr() as *mut u8);
        let slice = slice::from_raw_parts(buffer.as_ptr() as *const u8, len);
        let print = str::from_utf8_unchecked(slice);
        assert_eq!(print, "1.234");
    }