Performing math functionality with #[no_std]

    1. #![no_std]
    2. use panic_halt as _;
    3. use cortex_m_rt::entry;
    4. use cortex_m_semihosting::{debug, hprintln};
    5. use libm::{exp, floorf, sin, sqrtf};
    6. #[entry]
    7. fn main() -> ! {
    8. let floored_float = floorf(float);
    9. let sqrt_of_four = sqrtf(floored_float);
    10. let sinus_of_four = sin(floored_float.into());
    11. let exponential_of_four = exp(floored_float.into());
    12. hprintln!("Floored test float {} to {}", float, floored_float).unwrap();
    13. hprintln!("The square root of {} is {}", floored_float, sqrt_of_four).unwrap();
    14. hprintln!("The sinus of four is {}", sinus_of_four).unwrap();
    15. exponential_of_four
    16. )
    17. .unwrap();
    18. // exit QEMU
    19. // NOTE do not run this on hardware; it can corrupt OpenOCD state
    20. // debug::exit(debug::EXIT_SUCCESS);
    21. loop {}
    22. }