diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-06 02:20:51 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-06 02:20:51 +0000 |
commit | ff1b89a96d0f103ff0c917c458ddd3e36e9b3718 (patch) | |
tree | 5449bd61cebdf6486cb443c0013a8573204fb50c /lib/xsd/datatypes.rb | |
parent | 8a8dd6519948eaf207f03c12152fc160de7370a2 (diff) | |
download | ruby-ff1b89a96d0f103ff0c917c458ddd3e36e9b3718.tar.gz |
* import soap4r/1.5.2;
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
introduce SOAPExternalReference class as a referenct to SOAPEnvelope
external content.
* lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
with Attachments) support code by Jamie Herre.
* lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
streamHandler.rb,wsdlDriver.rb}: SwA support.
* lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
soaplet.rb}: SwA support and refactoring.
* lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
SOAPReference#initialize signature change.
* lib/soap/mapping/factory.rb: deleted unused methods.
* lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
string <-> Ruby class name matching.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
1.4e-45. 1.4e-45 is smaller than 2 ** -149...
* test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
* test/soap/test_streamhandler.rb: revert to the previous test that
warns "basic_auth unsupported under net/http".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/xsd/datatypes.rb')
-rw-r--r-- | lib/xsd/datatypes.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/xsd/datatypes.rb b/lib/xsd/datatypes.rb index f318e612b1..7223632b04 100644 --- a/lib/xsd/datatypes.rb +++ b/lib/xsd/datatypes.rb @@ -268,8 +268,11 @@ end module FloatConstants NaN = 0.0/0.0 - POSITIVE_INF = 1.0/0.0 + POSITIVE_INF = +1.0/0.0 NEGATIVE_INF = -1.0/0.0 + POSITIVE_ZERO = +1.0/POSITIVE_INF + NEGATIVE_ZERO = -1.0/POSITIVE_INF + MIN_POSITIVE_SINGLE = 2 ** -149 end class XSDFloat < XSDAnySimpleType @@ -320,7 +323,7 @@ private elsif @data.infinite? == -1 '-INF' else - sign = (1 / @data > 0.0) ? '+' : '-' + sign = XSDFloat.positive?(@data) ? '+' : '-' sign + sprintf("%.10g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 } end end @@ -329,11 +332,16 @@ private def narrow32bit(f) if f.nan? || f.infinite? f + elsif f.abs < MIN_POSITIVE_SINGLE + XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO else - packed = [f].pack("f") - (/\A\0*\z/ =~ packed)? 0.0 : f + f end end + + def self.positive?(value) + (1 / value) > 0.0 + end end # Ruby's Float is double-precision 64-bit floating point value. |