// CastToFloat16 takes an interface{} type or any Object type and
// attempts to convert it to the Float16 Object type.
CastToFloat16 takes an interface{} type or any Object type and
attempts to convert it to the Float16 Object type.
// CastToFloat16 takes an interface {} type or any Object type and // attempts to convert it to the Float16 Object type .
func CastToFloat16(v interface{}) (Float16, bool) {
	switch pt := v.(type) {
	case *Float16:
		return *pt, true
	case Float16:
		return pt, true
	case *float16.Num:
		t := *pt
		return Float16(t), true
	case float16.Num:
		t := pt
		return Float16(t), true
	case *Boolean:
		t := *pt
		return func(t Boolean) Float16 {
			if t {
				return Float16(float16.New(1))
			}
			return Float16(float16.New(0))
		}(t), true
	case Boolean:
		t := pt
		return func(t Boolean) Float16 {
			if t {
				return Float16(float16.New(1))
			}
			return Float16(float16.New(0))
		}(t), true
	case *Float32:
		t := *pt
		return Float16(float16.New(float32(t))), true
	case Float32:
		t := pt
		return Float16(float16.New(float32(t))), true
	default:
		return Float16(float16.New(0)), false
	}
}
func CastToFloat16 ( v interface { } ) ( Float16 , bool ) { switch pt := v . ( type ) { case * Float16 : return * pt , true case Float16 : return pt , true case * float16 . Num : t := * pt return Float16 ( t ) , true case float16 . Num : t := pt return Float16 ( t ) , true case * Boolean : t := * pt return func ( t Boolean ) Float16 { if t { return Float16 ( float16 . New ( 1 ) ) } return Float16 ( float16 . New ( 0 ) ) } ( t ) , true case Boolean : t := pt return func ( t Boolean ) Float16 { if t { return Float16 ( float16 . New ( 1 ) ) } return Float16 ( float16 . New ( 0 ) ) } ( t ) , true case * Float32 : t := * pt return Float16 ( float16 . New ( float32 ( t ) ) ) , true case Float32 : t := pt return Float16 ( float16 . New ( float32 ( t ) ) ) , true default : return Float16 ( float16 . New ( 0 ) ) , false } }
CastToFloat16 takes an interface{} type or any Object type and
attempts to convert it to the Float16 Object type.
CastToFloat16 takes an interface {} type or any Object type and attempts to convert it to the Float16 Object type .
// Also handles when v is nil