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, #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
26
27
# File 'lib/maxima/float.rb', line 18

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

#derivative(v: nil) ⇒ Object



41
42
43
# File 'lib/maxima/float.rb', line 41

def derivative(v: nil)
  ZERO
end

#imaginary?Boolean

Returns:



37
38
39
# File 'lib/maxima/float.rb', line 37

def imaginary?
  false
end

#real?Boolean

Returns:



33
34
35
# File 'lib/maxima/float.rb', line 33

def real?
  true
end

#to_fObject



29
30
31
# File 'lib/maxima/float.rb', line 29

def to_f
  @real
end