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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/istox/helpers/f_math.rb +19 -3
- data/lib/istox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d52eb93cd445733dd52722f77d352e404041fdc4a6319ff781d05b85a6f3bb
|
4
|
+
data.tar.gz: 357c6125becc02cd00be61713c4d1795f537757031f8bf60d0adb073fd854b8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84462df9231f6455710b9e9d0ae6b7ec24681269d75a8afed4ae5785cdb109ed7b2a492ebeecb8dbb89a77f6a705842ddbcd0605212f293f9208025caa54c786
|
7
|
+
data.tar.gz: '0917f90f1f2719a4f01f808ff400dc1fdb743bba0975fb6fd2d5357c95f88a551cc7192a1d254cdc70e42f7a45a3257b05d0560e4c163cc2f1a5c8d164b1ba58'
|
data/Gemfile.lock
CHANGED
data/lib/istox/helpers/f_math.rb
CHANGED
@@ -44,10 +44,15 @@ module Istox
|
|
44
44
|
x = 0 if x.blank?
|
45
45
|
y = 0 if y.blank?
|
46
46
|
|
47
|
-
x =
|
48
|
-
y =
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2019-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|