Enum Class BinaryPrefix

java.lang.Object
java.lang.Enum<BinaryPrefix>
org.openjdk.jmc.common.unit.BinaryPrefix
All Implemented Interfaces:
Serializable, Comparable<BinaryPrefix>, Constable, IPrefix<BinaryPrefix>

public enum BinaryPrefix extends Enum<BinaryPrefix> implements IPrefix<BinaryPrefix>
Binary prefixes, as standardized by IEC. The corresponding SI prefixes are also provided to reflect common usage. (JEDEC defines these to be used for powers of 1024 as well, except that they too capitalize "k".) Extend functionality as needed, perhaps like TimeUnit.
  • Enum Constant Details

  • Field Details

    • prefixSI

      @Deprecated public final DecimalPrefix prefixSI
      Deprecated.
      Accept that kilobytes and kibibytes are different units.
      Temporary reference to the corresponding decimal prefix to get the full name, only to be used during the transition phase where JMC hasn't been completely converted to use quantities. Do not rely on this.
    • symbolSI

      public final String symbolSI
    • symbolJEDEC

      public final String symbolJEDEC
    • symbolIEC

      public final String symbolIEC
    • englishName

      public final String englishName
    • localizedName

      public final String localizedName
  • Method Details

    • values

      public static BinaryPrefix[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BinaryPrefix valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • shift

      public int shift()
    • log1024

      public int log1024()
    • convertTo

      public long convertTo(long value)
    • convertTo

      public float convertTo(float value)
    • convertTo

      public double convertTo(double value)
    • getFloorLog2

      public static int getFloorLog2(long value)
      The base 2 logarithm. Note that for the value 0, 0 is returned in order to be consistent with Math.floor(double).
      Returns:
      the floor of the base 2 logarithm of the absolute value of value
    • getFloorLog1024

      public static int getFloorLog1024(long value)
      The base 1024 logarithm. Note that for the value 0, 0 is returned in order to be consistent with Math.floor(double).
      Returns:
      the floor of the base 1024 logarithm of the absolute value of value
    • getFloorPrefix

      public static BinaryPrefix getFloorPrefix(long value)
    • getAlignmentLog2

      public static int getAlignmentLog2(long value)
      The base 2 logarithm of the binary alignment of value. Note that for the value 0, the return value is undefined.
      Returns:
      the base 2 logarithm of the alignment of value
    • getAlignmentLog1024

      public static int getAlignmentLog1024(long value)
      The base 1024 logarithm of the binary alignment of value. Note that for the value 0, the return value is undefined.
      Returns:
      the base 1024 logarithm of the alignment of value
    • getFloorLog2

      public static int getFloorLog2(double value)
      The base 2 logarithm. Note that for the value 0, 0 is returned, in order to be consistent with Math.floor(double).
      Returns:
      the floor of the base 2 logarithm of the absolute value of value
    • getFloorLog1024

      public static int getFloorLog1024(double value)
      The base 1024 logarithm. Note that for the value 0, 0 is returned in order to be consistent with Math.floor(double).
      Returns:
      the floor of the base 1024 logarithm of the absolute value of value
    • getFloorPrefix

      public static BinaryPrefix getFloorPrefix(double value)
    • getAlignmentLog2

      public static int getAlignmentLog2(double value)
      The base 2 logarithm of the binary alignment of value. Note that for zero, infinity, NaN, and denormalized values, the return value is currently undefined.
      Returns:
      the base 2 logarithm of the alignment of value
    • getAlignmentLog1024

      public static int getAlignmentLog1024(double value)
      The base 1024 logarithm of the binary alignment of value. Note that for zero, infinity, NaN, and denormalized values, the return value is currently undefined.
      Returns:
      the base 1024 logarithm of the alignment of value
    • identifier

      public String identifier()
      Specified by:
      identifier in interface IPrefix<BinaryPrefix>
      Returns:
      identifier usable for constructing persistable identifiers for units.
    • symbol

      public String symbol()
      Specified by:
      symbol in interface IPrefix<BinaryPrefix>
      Returns:
      the symbol normally used to present this prefix in a GUI.
    • altSymbol

      public String altSymbol()
      Description copied from interface: IPrefix
      An alternative symbol. Intended to be used for interactive parsing where entering the micron character may be cumbersome, or catching typing of MB when intending MiB. (These are very different cases, and should ideally not be handled by the same mechanism. However, a single mechanism seems to work right now.)
      Specified by:
      altSymbol in interface IPrefix<BinaryPrefix>
      Returns:
      alternative symbol, or null if no other representation is available
    • localizedName

      public String localizedName()
      Specified by:
      localizedName in interface IPrefix<BinaryPrefix>
    • asExponentialStringBuilder

      public StringBuilder asExponentialStringBuilder(boolean multiplicationSign)
      Specified by:
      asExponentialStringBuilder in interface IPrefix<BinaryPrefix>
    • scaleFactor

      public BinaryScaleFactor scaleFactor()
      Specified by:
      scaleFactor in interface IPrefix<BinaryPrefix>
    • valueFactorTo

      public BinaryScaleFactor valueFactorTo(BinaryPrefix targetPrefix)
      Specified by:
      valueFactorTo in interface IPrefix<BinaryPrefix>
    • createUnitSelector

      public LinearKindOfQuantity.LinearUnitSelector createUnitSelector(LinearKindOfQuantity kindOfQuantity, Iterable<BinaryPrefix> prefixes)
      Specified by:
      createUnitSelector in interface IPrefix<BinaryPrefix>