Package org.xtce.math

Class MilStd1750A


  • public class MilStd1750A
    extends Object
    This class supports the MILSTD-1750A encoding and decoding by allowing for conversion from 16, 32, and 48 bit floating point values, in MILSTD 1750A representation to and from native IEEE754 representation for use in Java. It would have been preferred to use a freely available library for this, but the author was unable to locate one at the time of need. Note that the integer 16 bit form is not supported by this class. One document indicates that it isn't formally part of the standard (although discussed) and it appears that this is just "signMagnitude" of 16 bit integer encoding size. As a result, it was already supported, but by a different name. The logic used to implement this class is based on the logic used in the CPAN Convert::MIL1750A perl module by Jared Clarke, ASRC Aerospace. Much thanks for the help there.
    Author:
    dovereem
    • Constructor Summary

      Constructors 
      Constructor Description
      MilStd1750A​(double value, int encodingSize)
      Constructor for native IEEE754 representations of a raw MILSTD 1750A floating point number.
      MilStd1750A​(BigInteger value, int encodingSize)
      Constructor for base 10 or base 16 representations of a raw MILSTD 1750A floating point representation.
    • Constructor Detail

      • MilStd1750A

        public MilStd1750A​(BigInteger value,
                           int encodingSize)
        Constructor for base 10 or base 16 representations of a raw MILSTD 1750A floating point representation.
        Parameters:
        value - BigInteger containing the value as it would be raw encoded.
        encodingSize - int containing the number of bits represented.
        Throws:
        IllegalArgumentException - in the event that the encoding size is not one of the allowable values of 16, 32, or 48.
      • MilStd1750A

        public MilStd1750A​(double value,
                           int encodingSize)
        Constructor for native IEEE754 representations of a raw MILSTD 1750A floating point number.
        Parameters:
        value - double containing the IEEE754 native representation of a value to be encoded in MILSTD 1750A.
        encodingSize - int containing the number of bits to be represented.
        Throws:
        IllegalArgumentException - in the event that the encoding size is not one of the allowable values of 16, 32, or 48.
    • Method Detail

      • toIeeeDouble

        public double toIeeeDouble()
        Retrieves this MILSTD modeled value as an IEEE754 double, which is the native representation for Java.
        Returns:
        double containing the value represented.
      • toRawBits

        public long toRawBits()
        Retrieves this MILSTD modeled value as a raw binary value, in the form of a long integer representation for binary encoding.
        Returns:
        long containing the MILSTD value as encoded to raw bits.
      • toString

        public String toString()
        Retrieves this MILSTD modeled value as a string printable floating point value.
        Overrides:
        toString in class Object
        Returns:
        String containing the floating point value representation.