oj 3.10.3 → 3.10.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dab33e0024a7f3a4804bec003954f36fe21513bef170dfbc2e7efa9404af5958
4
- data.tar.gz: ffc7b2b24406ea40d9cc312bfe466d3a4716e9e48dfc662e61519a10d12f2918
3
+ metadata.gz: 3c5237f8fde35d255bce0e58bbb8de4cd74e6e1f8ea563ce6413eeec4605ec46
4
+ data.tar.gz: 97eeb9614491ed377ad2336bda388e0d3eeac843d61d4afea44e80bcf9e7782b
5
5
  SHA512:
6
- metadata.gz: 52cf7dcce0aaf3d1dfd2e13265032f38c50587f73607f1c23e432e385d11f2e611bc670edd11002b9310892fb7f5589f775b83d65599dfb235b2ae8ad411462b
7
- data.tar.gz: e6739fad6ff44371f051bc4b51aea8f748e0bd34cf84f75ac7bd2761b1e43dedae72bcc4c74621088242cf684ffee2aea6cb383ba74d0862b853e2bd141f57e8
6
+ metadata.gz: 7fd89f9ca4e2ef290e4096d3d486f118ab5cf93b3b54f14b0873561f0ec486ab700ac04e3556db6bd7a82f53e81d10f00eb7ecb524a012266018b9b080c89726
7
+ data.tar.gz: 0436f2949fc7881f194c6f781f489a9a47dbacb630390308fc1b48c2e047cbbc160338ab51f94998c9a08f39e996c9db27a4dd341d7870299de78d41f2d8a659
@@ -795,13 +795,13 @@ oj_num_as_value(NumInfo ni) {
795
795
  }
796
796
  } else {
797
797
  // All these machinations are to get rounding to work better.
798
- long double d = (long double)ni->i * (long double)ni->div + (long double)ni->num;
798
+ long double ld = (long double)ni->i * (long double)ni->div + (long double)ni->num;
799
799
  int x = (int)((int64_t)ni->exp - ni->di);
800
800
 
801
801
  // Rounding sometimes cuts off the last digit even if there are only
802
802
  // 15 digits. This attempts to fix those few cases where this
803
803
  // occurs.
804
- if ((long double)INT64_MAX > d && (int64_t)d != (ni->i * ni->div + ni->num)) {
804
+ if ((long double)INT64_MAX > ld && (int64_t)ld != (ni->i * ni->div + ni->num)) {
805
805
  volatile VALUE bd = rb_str_new(ni->str, ni->len);
806
806
 
807
807
  rnum = rb_rescue2(parse_big_decimal, bd, rescue_big_decimal, bd, rb_eException, 0);
@@ -809,16 +809,23 @@ oj_num_as_value(NumInfo ni) {
809
809
  rnum = rb_funcall(rnum, rb_intern("to_f"), 0);
810
810
  }
811
811
  } else {
812
- d = roundl(d);
812
+ double d;
813
+
814
+ ld = roundl(ld);
815
+ // You would expect that staying with a long double would be
816
+ // more accurate but it fails to match what Ruby generates so
817
+ // drop down to a double.
813
818
  if (0 < x) {
814
- d *= powl(10.0L, x);
819
+ d = (double)ld * pow(10.0, x);
815
820
  } else if (0 > x) {
816
- d /= powl(10.0L, -x);
821
+ d = (double)ld / pow(10.0, -x);
822
+ } else {
823
+ d = (double)ld;
817
824
  }
818
825
  if (ni->neg) {
819
826
  d = -d;
820
827
  }
821
- rnum = rb_float_new((double)d);
828
+ rnum = rb_float_new(d);
822
829
  }
823
830
  }
824
831
  }
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.10.3'
4
+ VERSION = '3.10.5'
5
5
  end
@@ -15,7 +15,7 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
15
15
  def setup
16
16
  @hash = {
17
17
  'a' => 2,
18
- 'b' => 3.141,
18
+ 'b' => 5.23683071,
19
19
  'c' => 'c',
20
20
  'd' => [ 1, "b", 3.14 ],
21
21
  'e' => { 'foo' => 'bar' },
@@ -23,7 +23,7 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
23
23
  'h' => 1000.0,
24
24
  'i' => 0.001
25
25
  }
26
- @json = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},'\
26
+ @json = '{"a":2,"b":5.23683071,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},'\
27
27
  '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}'
28
28
  end
29
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.3
4
+ version: 3.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler