[riot-notifications] [RIOT-OS/RIOT] cpu/native: Allow Access to Hardware SPI Bus on Linux (#11352)

Frank Hessel notifications at github.com
Mon Sep 30 21:42:38 CEST 2019


Regarding your suggested change to just cast to `int` here – is it valid to assume that `int` is always 32 bit? Otherwise casting would cause undefined behavior: `fractional` is within the [0.0, 1.0) interval, so multiplying it by `10000000.f` would clearly exceed the boundaries of a 16 bit `int`. Wouldn't casting to `long` and using `labs()` be a more general solution then (note also the change from `%07u` to `%07lu`)?

```c
printf("0x%04" PRIx16 " %7" PRId32 " mC %4d.%07lu C)\n", raw, millicelsius,
  (int)integral, labs((long) (fractional * 10000000.f)));
```

This might not be a problem with the native CPU, but maybe it is for some other boards?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11352#issuecomment-536720416
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190930/737ad28d/attachment-0001.htm>


More information about the notifications mailing list