Thank you for making this library, it really helps a lot in my work.
But recently, I have found that when I use half_cast() to convert the minimum value of short type (-32768) to half, I get -1, but it should be -32768. This problem also occurs when converting the minimum value of int type. I'm not sure, but it may be related to the overflow in half. hpp: 1082 line, or did I miss something?
Yes, there is indeed a bug in the integer to half conversion when calling it with the type's minimum negative value, since on two's complement platforms (which is virtually everywhere) that doesn't have a positive equivalent inside the type's own domain. I will look into fixing it.
Thank you for bringing this up.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Thank you for making this library, it really helps a lot in my work.
But recently, I have found that when I use
half_cast()
to convert the minimum value ofshort
type (-32768) tohalf
, I get -1, but it should be -32768. This problem also occurs when converting the minimum value ofint
type. I'm not sure, but it may be related to the overflow in half. hpp: 1082 line, or did I miss something?The following code can reproduce this issue.
Yes, there is indeed a bug in the integer to half conversion when calling it with the type's minimum negative value, since on two's complement platforms (which is virtually everywhere) that doesn't have a positive equivalent inside the type's own domain. I will look into fixing it.
Thank you for bringing this up.