sepavloff added inline comments.
================ Comment at: clang/lib/AST/Interp/Floating.h:54-62 + explicit operator int8_t() const { return toAPSInt().getExtValue(); } + explicit operator uint8_t() const { return toAPSInt().getExtValue(); } + explicit operator int16_t() const { return toAPSInt().getExtValue(); } + explicit operator uint16_t() const { return toAPSInt().getExtValue(); } + explicit operator int32_t() const { return toAPSInt().getExtValue(); } + explicit operator uint32_t() const { return toAPSInt().getExtValue(); } + explicit operator int64_t() const { return toAPSInt().getExtValue(); } ---------------- tbaeder wrote: > sepavloff wrote: > > Conversions to integers are bitcasts+truncation but the conversion to bool > > is different. What semantics have these operations? > They are basically used for casting. I didn't mean to make the bool > implementation different, just seemed to make sense to me to do it this way. If they are used for casting, they need to preserve value, that is conversion float->int32 should transform 1.0->0x00000001. The method `toAPSInt` uses bitcast, so it converts 1.0->0x3f800000. `APFloat::convertToInteger` should be used to make value-preverving conversion but it requires knowledge of rounding mode. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134859/new/ https://reviews.llvm.org/D134859 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits