Skip to content

Request to Support Decoding Double Type in float32 Method #353

@funplusxxx

Description

@funplusxxx

I was examining the source code of msgpack and noticed that the float32 method in the decode_number.go file does not support decoding of double type values.

Here is the code snippet:

func (d *Decoder) float32(c codes.Code) (float32, error) {
	if c == codes.Float {
		n, err := d.uint32()
		if err != nil {
			return 0, err
		}
		return math.Float32frombits(n), nil
	}

	n, err := d.int(c)
	if err != nil {
		return 0, fmt.Errorf("msgpack: invalid code=%x decoding float32", c)
	}
	return float32(n), nil
}

As you can see, the method currently only supports decoding of float and integer types. I was wondering if there are any plans to extend this functionality to include support for decoding double type values as well. This could be beneficial for users who need to decode double type values into float32.

Thank you for your attention to this matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions