---
title: "Comment by Christian Foucher on \"ESP32 Standard Library Embedded Rust: Analog Temperature Sensing using the ADC\" | Hashnode"
description: "Hello Omar, Do you know what happens when the adc.read function returns 0 ? Temperature computation will do a floating division by 0 (=+INF). I have tested on W"
url: "https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb"
---

[Discussion](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c)

Comment [ESP32 Standard Library Embedded Rust: Analog Temperature Sensing using the ADC](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c)

[Christian Foucher](https://hashnode.com/@Valda60)

[Aug 24, 2023](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb)

Hello Omar, Do you know what happens when the adc.read function returns 0 ? Temperature computation will do a floating division by 0 (=+INF). I have tested on Wokwi, it seems OK (Temperature -273.15 Celcius). Rust follows the IEEE 754 rules.

[Omar Hiari](https://hashnode.com/@omarhiari)

[Aug 24, 2023](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb#reply-64e733962a4db2f775273654)

Thanks for pointing it out. I actually haven't tested for that case, however, it seems that dividing by zero in floating point (f32 or f64) does not panic in Rust. Instead, it results in a NaN (Not a Number) and continues operation. Here's where I found some insight:

[users.rust-lang.org/t/how-should-i-handle-f64-div…](https://users.rust-lang.org/t/how-should-i-handle-f64-division-by-zero-panic-elegantly/32485)

[internals.rust-lang.org/t/should-x-0-be-an-error/…](https://internals.rust-lang.org/t/should-x-0-be-an-error/2252)

[Christian Foucher](https://hashnode.com/@Valda60)

[Aug 25, 2023](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb#reply-64e8ad5cf659a80ea33ed576)

[Omar Hiari](https://hashnode.com/@omarhiari) [play.rust-lang.org](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d62f808a88b8798568ad0323173f36e2)
