[riot-notifications] [RIOT-OS/RIOT] tests/driver_sht2x: avoid negative number after decimal dot (#12164)

Kees Bakker notifications at github.com
Tue Sep 3 21:11:44 CEST 2019

In the sht3x test there is this:
        int16_t temp;
        int16_t hum;

        if ((res = sht3x_read(&dev, &temp, &hum)) == SHT3X_OK) {
            printf("Temperature [°C]: %d.%d\n"
                   "Relative Humidity [%%]: %d.%d\n"
                   temp / 100, temp % 100,
                   hum / 100, hum % 100);
Not only does it need an abs() for the numbers after decimal dot, it has `%d` for a 2 digit number. This means that a temperature of `10.05` degrees will be printed as `10.5`. Same for the humidity. I don't have the device so I can't really test.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190903/cf3cecd7/attachment.htm>

More information about the notifications mailing list