[libre-riscv-dev] bug in sfpy on FP16 integer initialisation
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Wed Jul 17 08:29:47 BST 2019
ha! that worked!
>>> from sfpy import float
>>> dir(float)
[.... 'ui32_to_f32']
>>> float.ui32_to_f32(5)
Float32(5.0)
>>> float.ui32_to_f32(50)
Float32(50.0)
>>> float.ui32_to_f32(1<<32)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sfpy/float.pyx", line 681, in sfpy.float.ui32_to_f32
OverflowError: value too large to convert to uint32_t
>>> float.ui32_to_f32(1<<31)
Float32(2147483648.0)
On Wed, Jul 17, 2019 at 8:25 AM Luke Kenneth Casson Leighton
<lkcl at lkcl.net> wrote:
>
> On Wed, Jul 17, 2019 at 8:22 AM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> > bug resolved as instance of forgetting to read the docs, see comments on
> > bugzilla
>
> :)
>
> still need your help, bill - i'm currently investigating the addition
> of uin32_to_f32 (etc.) explicitly to sfpy.float:
>
> --- a/sfpy/float.pyx
> +++ b/sfpy/float.pyx
> @@ -676,6 +676,11 @@ cdef class Float32:
> cdef cfloat.float64_t f = cfloat.f32_to_f64(self._c_float)
> return Float64.from_c_float(f)
>
> +# integer conversions
> +
> +cpdef Float32 ui32_to_f32(uint32_t value):
> + cdef cfloat.float32_t f = cfloat.ui32_to_f32(value)
> + return Float32.from_c_float(f)
More information about the libre-riscv-dev
mailing list