How do I cast float64 to sequence of byte`s and cast sequence of `byte`s to `float64? float64 is just an example it could be any basic type. I already did it for an array, but don't know how to do it for a sequence.
Thanks
See
http://ssalewski.de/nimprogramming.html#_casts_and_type_conversion
first. Then it should be easy to cast a float to an array of 8 bytes and back. And when you have a seq containing exactly 8 bytes, then you can copy the 8 bytes of your array to the seq and back.
So it should become clear that a direct cast between seq and float is not possible, as both data structures are very different. The seq has its buffer which contains the elements, but also a length and capacity field at least.
I think the only operation what you may do is to cast the buffer of the seq to a float, at least you can copy the buffer of the seq to a float byte by byte. But you have to take into account that the buffer of the seq may be invalidated when you change the seq -- when you grow the seq it may allocate a new buffer and old buffer may be freed. Note, the address of the buffer of the seq is the addr of the first element, that is element with subscript 0.