Class: Maxima::Float

Inherits:
Unit
  • Object
show all
Defined in:
lib/maxima/float.rb

Constant Summary collapse

ZERO =
Float.new(0).freeze

Instance Attribute Summary collapse

Attributes inherited from Unit

#maxima_output, #plot_title

Instance Method Summary collapse

Methods inherited from Unit

#==, #===, #at, #gnu_plot_options, #gnu_plot_text, #gnu_plot_w, #inspect, #negative?, parse, parse_float, #positive?, #simplified, #through_maxima, #to_gnu_plot, #to_maxima_input, #to_pdf, #to_s, #with_plot_title, #zero?

Constructor Details

#initialize(real = nil, **options) ⇒ Float

Returns a new instance of Float.



12
13
14
15
16
# File 'lib/maxima/float.rb', line 12

def initialize(real = nil, **options)
  options[:maxima_output] ||= real&.to_s
  super(**options)
  @real = (real || @maxima_output).to_f
end

Instance Attribute Details

#realObject

Returns the value of attribute real.



10
11
12
# File 'lib/maxima/float.rb', line 10

def real
  @real
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/maxima/float.rb', line 18

def <=>(other)
  case other
  when ::Float, Float
    @real <=> other.to_f
  else
    -1
  end
end

#derivative(v: nil) ⇒ Object



39
40
41
# File 'lib/maxima/float.rb', line 39

def derivative(v: nil)
  ZERO
end

#imaginary?Boolean

Returns:



35
36
37
# File 'lib/maxima/float.rb', line 35

def imaginary?
  false
end

#real?Boolean

Returns:



31
32
33
# File 'lib/maxima/float.rb', line 31

def real?
  true
end

#to_fObject



27
28
29
# File 'lib/maxima/float.rb', line 27

def to_f
  @real
end