Class RealValue

java.lang.Object
svm.value.Value
svm.value.RealValue

public class RealValue extends Value

RealValue.

real_value ::= c-real real_literal:string

A real literal is a string:

	<sign>? <digit>* < . <digit>+ >? < & <sign>? <digit>+ >?

Note that a real literal may not contain spaces.

Link to GitHub: Source File.

Author:
S-Port: Definition of S-code, Øystein Myhre Andersen
  • Field Details

    • value

      public float value
      The float value
  • Constructor Details

    • RealValue

      public RealValue()
      Default Constructor
    • RealValue

      private RealValue(float value)
      Construct a new LongRealValue
      Parameters:
      value - the float value
  • Method Details

    • of

      public static RealValue of(float value)
      Create a new RealValue with the given parameter
      Parameters:
      value - the double value
      Returns:
      an RealValue or null
    • ofScode

      public static RealValue ofScode()
      Scans the remaining S-Code belonging to this real_value. Then construct a new RealValue object.
      Returns:
      that RealValue object or null.
    • emit

      public void emit(DataSegment dseg)
      Description copied from class: Value
      Add this value to the given DataSegment
      Overrides:
      emit in class Value
      Parameters:
      dseg - the DataSegment
    • neg

      public Value neg()
      Description copied from class: Value
      Returns the negative value of this Value object.
      Overrides:
      neg in class Value
      Returns:
      the negative value of this Value object.
    • toFloat

      public float toFloat()
      Description copied from class: Value
      Returns the float value of this Value object.
      Overrides:
      toFloat in class Value
      Returns:
      the float value of this Value object.
    • toDouble

      public double toDouble()
      Description copied from class: Value
      Returns the double value of this Value object.
      Overrides:
      toDouble in class Value
      Returns:
      the double value of this Value object.
    • add

      public Value add(Value other)
      Description copied from class: Value
      Returns the result of: this value + other value
      Overrides:
      add in class Value
      Parameters:
      other - the other value
      Returns:
      the result of: this value + other value
    • sub

      public Value sub(Value other)
      Description copied from class: Value
      Returns the result of: this value - other value
      Overrides:
      sub in class Value
      Parameters:
      other - the other value
      Returns:
      the result of: this value - other value
    • mult

      public Value mult(Value other)
      Description copied from class: Value
      Returns the result of: this value * other value
      Overrides:
      mult in class Value
      Parameters:
      other - the other value
      Returns:
      the result of: this value * other value
    • div

      public Value div(Value other)
      Description copied from class: Value
      Returns the result of: this value / other value
      Overrides:
      div in class Value
      Parameters:
      other - the other value
      Returns:
      the result of: this value / other value
    • compare

      public boolean compare(int relation, Value other)
      Description copied from class: Value
      Compare this Value with the given Value according to the given relation.
      Overrides:
      compare in class Value
      Parameters:
      relation - one of: LT, LE, EQ, GE, GT, NE
      other - the other Value
      Returns:
      true: if the relation holds
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • write

      public void write(AttributeOutputStream oupt) throws IOException
      Description copied from class: Value
      Writes this Value to the given output.
      Overrides:
      write in class Value
      Parameters:
      oupt - the output stream
      Throws:
      IOException - if IOException occur
    • read

      public static RealValue read(AttributeInputStream inpt) throws IOException
      Reads a BooleanValue from the given input.
      Parameters:
      inpt - the AttributeInputStream
      Returns:
      the BooleanValue read
      Throws:
      IOException - if IOException occur