Exception: Decimal::InvalidOperation

Inherits:
Exception
  • Object
show all
Defined in:
lib/decimal/decimal.rb

Overview

Invalid operation exception.

The result of the operation is a quiet positive NaN, except when the cause is a signaling NaN, in which case the result is also a quiet NaN, but with the original sign, and an optional diagnostic information.

Direct Known Subclasses

ConversionSyntax

Instance Attribute Summary

Attributes inherited from Exception

#context

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context = nil, *args) ⇒ InvalidOperation

Returns a new instance of InvalidOperation.



110
111
112
113
# File 'lib/decimal/decimal.rb', line 110

def initialize(context=nil, *args)
  @value = args.first if args.size>0
  super context
end

Class Method Details

.handle(context = nil, *args) ⇒ Object



102
103
104
105
106
107
108
109
# File 'lib/decimal/decimal.rb', line 102

def self.handle(context=nil, *args)
  if args.size>0
    sign, coeff, exp = args.first.split
    Decimal.new([sign, coeff, :nan])._fix_nan(context)
  else
    Decimal.nan
  end
end