Sha256: bbbefc3483d41171ccd5f88b1ea7177fef72fa5ac4432782a1fd9951fa6967f2
Contents?: true
Size: 624 Bytes
Versions: 3
Compression:
Stored size: 624 Bytes
Contents
# pops the top item of the +:float+ stack; # pushes a ValuePoint with its square root onto the +:float+ stack # # note: pushes an +:error+ item if the value is negative # # *needs:* 1 +:float+ # # *pushes:* 1 +:float+ # class FloatSqrtInstruction < Instruction def preconditions? needs :float, 1 end def setup @arg1 = @context.pop_value(:float) end def derive if @arg1 >= 0.0 @result = ValuePoint.new("float", Math.sqrt(@arg1)) else raise Instruction::NaNResultError, "#{self.class.to_nudgecode} did not return a float" end end def cleanup pushes :float, @result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nudge-0.2.9 | lib/instructions/float/float_sqrt.rb |
nudge-0.2.8 | lib/instructions/float/float_sqrt.rb |
nudge-0.2.7 | lib/instructions/float/float_sqrt.rb |