Both-Endian Numerics Support #10

Closed
opened 2026-01-29 21:16:29 +00:00 by claunia · 4 comments
Owner

Originally created by @mnadareski on GitHub (Oct 23, 2025).

Originally assigned to: @mnadareski on GitHub.

To extend work that is currently being done, both-endian numerics should be implemented fully.

  • Include 8-, 16-, 32-, and 64-bit numerics. U/Int128 should not be targeted at this time
  • Conversion to and from primitive types based on the endianness of the machine
  • Support all mathematical operations (+, -, *, /, ^)
  • Include read-only properties for each endianness value directly
  • Add a validating property to easily check if both values match

This should live in the IO repository under the SabreTools.Numerics namespace including extensions for reading and writing like any other numeric type.

Originally created by @mnadareski on GitHub (Oct 23, 2025). Originally assigned to: @mnadareski on GitHub. To extend work that is currently being done, both-endian numerics should be implemented fully. - Include 8-, 16-, 32-, and 64-bit numerics. U/Int128 should not be targeted at this time - Conversion to and from primitive types based on the endianness of the machine - Support all mathematical operations (`+`, `-`, `*`, `/`, `^`) - Include read-only properties for each endianness value directly - Add a validating property to easily check if both values match This should live in the IO repository under the `SabreTools.Numerics` namespace including extensions for reading and writing like any other numeric type.
Author
Owner

@Deterous commented on GitHub (Oct 27, 2025):

Desirable features:

  • One-line assignment: e.g. obj.BothEndianInt32Value = data.ReadBytes(8); and obj.BothEndianInt16Value = data.ReadBytes(4); (that is, no need to do new BothEndianInt32();)
  • Some sort of property indicating whether both copies are matching or not: e.g. type.Matches or type.IsConsistent
  • Access to the individual values if they don't agree: e.g. type.LE and type.BE
  • All while still being able to treat the type as an integer: e.g. type = 1; and int num = type * 2; (defaulting to the LE value if they disagree? Or null or throw exception), as well as type.LE = 1 and int num = type.LE * 2
@Deterous commented on GitHub (Oct 27, 2025): Desirable features: - One-line assignment: e.g. `obj.BothEndianInt32Value = data.ReadBytes(8);` and `obj.BothEndianInt16Value = data.ReadBytes(4);` (that is, no need to do `new BothEndianInt32();`) - Some sort of property indicating whether both copies are matching or not: e.g. `type.Matches` or `type.IsConsistent` - Access to the individual values if they don't agree: e.g. `type.LE` and `type.BE` - All while still being able to treat the type as an integer: e.g. `type = 1;` and `int num = type * 2;` (defaulting to the LE value if they disagree? Or null or throw exception), as well as `type.LE = 1` and `int num = type.LE * 2`
Author
Owner

@mnadareski commented on GitHub (Oct 27, 2025):

A couple of notes to self on the above requests:

  • Extensions in IO will be needed, so this all may have to live in IO
  • Direct setting of a single endianness value may be problematic
  • Should treating as a normal numeric be system-aware?
@mnadareski commented on GitHub (Oct 27, 2025): A couple of notes to self on the above requests: - Extensions in IO will be needed, so this all may have to live in IO - Direct setting of a single endianness value may be problematic - Should treating as a normal numeric be system-aware?
Author
Owner

@mnadareski commented on GitHub (Oct 27, 2025):

This has been implemented in IO in the following commits:

@mnadareski commented on GitHub (Oct 27, 2025): This has been implemented in IO in the following commits: - https://github.com/SabreTools/SabreTools.IO/commit/8f06bf5859798677785f704641a5b9d71ae26042 - https://github.com/SabreTools/SabreTools.IO/commit/fb60f1fed5d4ca04a80d32ab289bf7a67a46d0bc - https://github.com/SabreTools/SabreTools.IO/commit/244b7411d47a0618e08bee7d8512b5fea6cbc7a8 - https://github.com/SabreTools/SabreTools.IO/commit/edd3e6eef27600fe4627b03d942540fd77019c45 - https://github.com/SabreTools/SabreTools.IO/commit/7c63f44c7573989b7ddfee34ae3046b0036c48ee
Author
Owner

@mnadareski commented on GitHub (Oct 28, 2025):

IO 1.8.0 has been published and is in current rolling.

@mnadareski commented on GitHub (Oct 28, 2025): IO 1.8.0 has been published and is in current rolling.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SabreTools/SabreTools.Serialization#10