%(other)
click to toggle source
def %(other)
n = other.to_f
f = @value % n
f = -f if @value < 0
f = -f if n < 0
@value = f
self
end
*(other)
click to toggle source
def *(other)
@value *= other.to_f
self
end
+(other)
click to toggle source
def +(other)
@value += other.to_f
self
end
-(other)
click to toggle source
def -(other)
@value -= other.to_f
self
end
-@()
click to toggle source
def -@
@value = -@value
self
end
/(other)
click to toggle source
def /(other)
@value /= other.to_f
self
end
==(other)
click to toggle source
def ==(other)
if other.is_a? XPathNodeSet or other.is_a? XPathBoolean then
other == self
else
@value == other.to_f
end
end
ceil()
click to toggle source
def ceil
@value = @value.ceil.to_f
self
end
floor()
click to toggle source
def floor
@value = @value.floor.to_f
self
end
round()
click to toggle source
def round
f = @value
unless f.nan? or f.infinite? then
if f >= 0.0 then
@value = f.round.to_f
elsif f - f.truncate >= -0.5 then
@value = f.ceil.to_f
else
@value = f.floor.to_f
end
end
self
end
to_f()
click to toggle source
to_number(context)
click to toggle source
def to_number(context)
self
end
to_predicate()
click to toggle source
def to_predicate
to_f
end
to_ruby()
click to toggle source
to_str()
click to toggle source
def to_str
if @value.nan? then
'NaN'
elsif @value.infinite? then
if @value < 0 then
'-Infinity'
else
'Infinity'
end
else
sprintf("%.100f", @value).gsub(/\.?0+\z/, '')
end
end
true?()
click to toggle source
def true?
@value != 0.0 and not @value.nan?
end