istox 0.1.75 → 0.1.76

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: f9753f2f41469c34295741fbb9583c55be00aa683da8b37cf527f3a69ebb4129
4
- data.tar.gz: 0c720e7acf4dd1b39f715c645cbdd739052136e367604177069bf1a777545b55
3
+ metadata.gz: 28d52eb93cd445733dd52722f77d352e404041fdc4a6319ff781d05b85a6f3bb
4
+ data.tar.gz: 357c6125becc02cd00be61713c4d1795f537757031f8bf60d0adb073fd854b8b
5
5
  SHA512:
6
- metadata.gz: c25907b11f9110a5d9f86f205d256cefd410fd461a4ddbe7e6e72d9411dd99ae10d1e162f3e342a6cda07b6a57beab6b46fce4590e3fbb7ff59072bd558da6fb
7
- data.tar.gz: 2d622f312e65b98d5c98e9e7506d16e9dcf7e79f7aa3eb8f6df9759b860924b0987af3393ffe7f2b2d27e9b7845316127720555516396c185354c5e600ed1846
6
+ metadata.gz: 84462df9231f6455710b9e9d0ae6b7ec24681269d75a8afed4ae5785cdb109ed7b2a492ebeecb8dbb89a77f6a705842ddbcd0605212f293f9208025caa54c786
7
+ data.tar.gz: '0917f90f1f2719a4f01f808ff400dc1fdb743bba0975fb6fd2d5357c95f88a551cc7192a1d254cdc70e42f7a45a3257b05d0560e4c163cc2f1a5c8d164b1ba58'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.74)
4
+ istox (0.1.75)
5
5
  binding_of_caller
6
6
  bunny (>= 2.12.0)
7
7
  graphlient
@@ -44,10 +44,15 @@ module Istox
44
44
  x = 0 if x.blank?
45
45
  y = 0 if y.blank?
46
46
 
47
- x = ::BigDecimal.new(x.to_s)
48
- y = ::BigDecimal.new(y.to_s)
47
+ x = to_fixed(x)
48
+ y = to_fixed(y)
49
+
50
+ fixed_1 = ::BigDecimal.new("1e18")
51
+ r_y = fixed_1.mult(fixed_1, 100).truncate(0).div(y, 100).truncate(0)
49
52
 
50
- return x.div(y, 100).truncate(18).to_s
53
+ result = from_fixed(x.mult(r_y, 100).truncate(0).div(fixed_1, 100).truncate(0))
54
+
55
+ return result.truncate(18).to_s
51
56
  end
52
57
 
53
58
  def round_up(x, digits)
@@ -62,6 +67,17 @@ module Istox
62
67
  ::BigDecimal.new(x.to_s).round(digits).to_s
63
68
  end
64
69
 
70
+ private
71
+
72
+ def to_fixed(x)
73
+ return ::BigDecimal.new(x.to_s).mult(::BigDecimal.new('1e18'), 100).truncate(18)
74
+ end
75
+
76
+ def from_fixed(x)
77
+ return ::BigDecimal.new(x.to_s).div(::BigDecimal.new('1e18'), 100).truncate(18)
78
+ end
79
+
80
+
65
81
  end
66
82
  end
67
83
  end
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = "0.1.75"
2
+ VERSION = "0.1.76"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.75
4
+ version: 0.1.76
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny