|| at Dec 9, 2013 at 1:42 pm
On 9 December 2013 13:28, matt wrote:
Is the only way to sign extend a value through use of casting between uint
e.g. if I want to sign-extend from the 16 bit boundary do I need to do the
val := uint32(0x0000ffff)
val = uint32(int32(val << 16) >> 16)
I'm not sure exactly what you're asking. If you have a signed 16-bit
value and you want to extend it to a signed 32-bit value, a simple
conversion  `int32(the16bitValue)` will do. If the 16-bit value is
unsigned but you want to pretend that its signed and then sign-
extend it, `int32(int16(theUnsigned16BitValue))` will do.
Does that make sense?
 Not a "cast". Go doesn't have casts. What C rolls together under
the cast umbrella, Go has conversions and type-assertions for.
(And unsafe, but there be shark-encrusted waters.)
Chris "allusive" Dollin
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/groups/opt_out.