eclipse-uprotocol / up-spec

uProtocol Specifications
Apache License 2.0
31 stars 25 forks source link

Use inclusive ranges for integer values #181

Closed gregmedd closed 2 months ago

gregmedd commented 2 months ago

In the uattributes spec, a mix of inclusive ([X, Y]) and exclusive ((X, Y)) range formats are used. Whenever the values for a range are integers, only inclusive ranges should be used to express the range to avoid confusion. Exclusive ranges only add meaning when discussing floating point values.

For example, one requirement reads:

The UUri's resource_id MUST be set to a value in the range [0x8000, 0xFFFF)

The range, as written, can be read as "any value starting at 0x8000 up to, but not including, 0xFFFF" - which requires mental subtraction to find the real maximum value of 0xFFFE. If only inclusive ranges are used instead, this reads more cleanly:

The UUri's resource_id MUST be set to a value in the range [0x8000, 0xFFFE]

In this form, it would be read as "any value from 0x8000 to 0xFFFE, inclusive". No additional interpretation is required to understand the minimum and maximum allowable values.

sophokles73 commented 2 months ago

Makes sense to me :+1: