Types

compared with
Current by Andrew Griffin
on Mar 05, 2010 13:04.

(show comment)
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (3)

View Page History
h1.Pre-Defined Fudge Types

These types are part of the built-in Fudge type dictionary, and *must* must be handled by any [Fudge Encoding Specification|Encoding Specification]-compliant system.

||Type ID (Decimal)||Type ID (Binary)||Fixed Width||Description||Java Type||
|28|0001 1100|Yes (12)|Reserved for [combined Date and Time|DateTime Encoding#DateTime]|Currently unspecified|

h1. Type Reductions
To maximise efficiency of a Fudge message, types can be reduced by a system. The following reductions must always take place:

||Type ||Reduce to||If ||
|16-bit integer|8-bit integer|Value is within smaller range|
|32-bit integer|8- or 16- bit integer|Value is within smaller range|
|64-bit integer|8-, 16- or 32- bit integer|Value is within smaller range|
|byte array|fixed length byte array|Length matches one of the fixed lengths|
|combined date and time|date|If the precision level does not include a time element|

Additional reductions are possible for some types, but their use is optional as there may be a high overhead of calculating if the conversion is possible or performing the conversion:

||Type ||Reduce to||If ||
|array of 16-bit integers|array of 8-bit integers|If the largest value in the array is within the 8-bit range|
|array of 32-bit integers|array of 8- or 16- bit integers|If the largest value in the array is within the smaller range|
|array of 64-bit integers|array of 8-, 16- or 32- bit integers|If the largest value in the array is within the smaller range|
|32-bit floating point|8- or 16- bit integer|If the floating point value can be exactly represented by a smaller integer (e.g. 0)|
|64-bit floating point|8-, 16- or 32- bit integer|If the floating point value can be exactly represented by a smaller integer (e.g. 0)|
|64-bit floating point|32-bit floating point|If the floating point value can be exactly represented by the lower precision type|
|array of 32-bit floating point|array of 8- or 16- bit integers|If all elements can be exactly represented by a smaller integer|
|array of 64-bit floating point|array of 8-, 16- or 32- bit integers, or array of 32-bit floating point|If all elements can be exactly represented by a smaller type|
|string|integer or floating point type|If the string contains a base-10 number within the range of an integer type, or a IEE754 ASCII floating point value that can be exactly represented by the 32- or 64- bit floating point type|

Even if these reductions are not implemented, an implementation should provide utility methods or other type conversion mechanism to expand received data to the type required or expected by an application.

h1. Runtime-Extended Types
Fudge is designed to have an extensible type system, so applications can add additional types for application or domain specific entity types. When processing Fudge-encoded data, where a Fudge implementation does not have the ability to process a particular type, the data will still be maintained so that it can be passed onto additional systems without loss of data.

To allow scope for the expansion of the standard Fudge types listed above while ensuring application compatibility, any type extensions MUST must be allocated from 255 (1111 1111) downwards. Any new types added to the standard will be allocated from 29 upwards.

h2. Runtime-Extended Fixed-Width Types