Skip to content

Floating-point serialization is platform-specific but works on modern standard computers #356

Description

@TysonAndre

https://en.wikipedia.org/wiki/Endianness#Floating_point

However, on modern standard computers (i.e., implementing IEEE 754), one may in practice safely assume that the endianness is the same for floating-point numbers as for integers, making the conversion straightforward regardless of data type

igbinary_unserialize_double/igbinary_serialize_double

Filing this to document it, though no bugs were reported

/** Serializes double. */
inline static int igbinary_serialize_double(struct igbinary_serialize_data *igsd, double d) {
	union {
		double d;
		uint64_t u;
	} u;

	u.d = d;

	return igbinary_serialize8_and_64(igsd, igbinary_type_double, u.u);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions