Skip to content

Commit 5d12df5

Browse files
yoctopucedpgeorge
authored andcommitted
py/obj: Make literals unsigned in float get/new functions.
Fixes gcc warning when -Wsign-conversion is on. Signed-off-by: Yoctopuce <[email protected]>
1 parent 9bb6b50 commit 5d12df5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py/obj.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
203203
union {
204204
mp_float_t f;
205205
mp_uint_t u;
206-
} num = {.u = ((mp_uint_t)o - 0x80800000) & ~3};
206+
} num = {.u = ((mp_uint_t)o - 0x80800000u) & ~3u};
207207
return num.f;
208208
}
209209
static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
210210
union {
211211
mp_float_t f;
212212
mp_uint_t u;
213213
} num = {.f = f};
214-
return (mp_obj_t)(((num.u & ~0x3) | 2) + 0x80800000);
214+
return (mp_obj_t)(((num.u & ~0x3u) | 2u) + 0x80800000u);
215215
}
216216
#endif
217217

0 commit comments

Comments
 (0)