Included Modules

Files

Class Index [+]

Quicksearch

XSD::XSDDouble

Ruby’s Float is double-precision 64-bit floating point value.

Constants

Type

Public Class Methods

new(value = nil) click to toggle source
     # File lib/xsd/datatypes.rb, line 386
386:   def initialize(value = nil)
387:     init(Type, value)
388:   end

Private Instance Methods

_to_s() click to toggle source
     # File lib/xsd/datatypes.rb, line 422
422:   def _to_s
423:     if @data.nan?
424:       'NaN'
425:     elsif @data.infinite? == 1
426:       'INF'
427:     elsif @data.infinite? == 1
428:       '-INF'
429:     else
430:       sign = (1 / @data > 0.0) ? '+' : '-'
431:       sign + sprintf("%.16g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
432:     end
433:   end
screen_data(value) click to toggle source
     # File lib/xsd/datatypes.rb, line 392
392:   def screen_data(value)
393:     # "NaN".to_f => 0 in some environment.  libc?
394:     if value.is_a?(Float)
395:       return value
396:     end
397:     str = value.to_s.strip
398:     if str == 'NaN'
399:       NaN
400:     elsif str == 'INF'
401:       POSITIVE_INF
402:     elsif str == '-INF'
403:       NEGATIVE_INF
404:     else
405:       begin
406:         return Float(str)
407:       rescue ArgumentError
408:         # '1.4e' cannot be parsed on some architecture.
409:         if /e\z/ =~ str
410:           begin
411:             return Float(str + '0')
412:           rescue ArgumentError
413:             raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.", $!)
414:           end
415:         else
416:           raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.", $!)
417:         end
418:       end
419:     end
420:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.