Skip to content

Commit e57e8df

Browse files
authored
Merge pull request #1878 from arturo-lang/upgrade-nim-to-2.2.2
Upgrade to Nim 2.2.2
2 parents a285640 + f7aa997 commit e57e8df

23 files changed

+92
-101
lines changed

Diff for: examples/rosetta/arithmetic - complex.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
a: 1.0+1.0i
22
b: 3.141592653589793+1.2i
33
a + b: 4.141592653589793+2.2i
4-
a * b: 1.941592653589793+4.341592653589793i
4+
a * b: 1.9415926535897932+4.341592653589793i
55
1 / a: 0.5-0.5i
66
neg a: -1.0-1.0i
77
conj a: 1.0-1.0i

Diff for: examples/rosetta/averages - root mean square.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.204836822995428
1+
6.2048368229954285

Diff for: examples/rosetta/benford's law.res

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
digit actual expected
2-
1 0.301 0.3010299956639811
3-
2 0.177 0.1760912590556812
2+
1 0.301 0.30102999566398114
3+
2 0.177 0.17609125905568124
44
3 0.125 0.1249387366082999
5-
4 0.095 0.09691001300805641
5+
4 0.095 0.0969100130080564
66
5 0.08 0.0791812460476248
77
6 0.067 0.06694678963061322
8-
7 0.056 0.05799194697768673
9-
8 0.053 0.05115252244738128
8+
7 0.056 0.057991946977686726
9+
8 0.053 0.051152522447381284
1010
9 0.045 0.04575749056067514

Diff for: examples/rosetta/calculating the value of e.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.718281828459046
1+
2.7182818284590455

Diff for: examples/rosetta/circles of given radius through two points.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Through points:
22
(x: 0.1234, y: 0.9876)
3-
(x: 0.8764999999999999, y: 0.2345)
3+
(x: 0.8765, y: 0.2345)
44
and radius 2.0, you can construct the following circles:
5-
(x: 1.863111801658189, y: 1.974211801658189, r: 2.0)
5+
(x: 1.8631118016581893, y: 1.974211801658189, r: 2.0)
66
(x: -0.8632118016581896, y: -0.7521118016581892, r: 2.0)
77

88
Through points:
@@ -20,7 +20,7 @@ and radius 2.0, you can construct the following circles:
2020

2121
Through points:
2222
(x: 0.1234, y: 0.9876)
23-
(x: 0.8764999999999999, y: 0.2345)
23+
(x: 0.8765, y: 0.2345)
2424
and radius 0.5, you can construct the following circles:
2525
ERROR: separation of points > diameter
2626

Diff for: examples/rosetta/continued fraction.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
1.414213562373095
2-
2.718281828459046
3-
3.141592653589544
2+
2.7182818284590464
3+
3.1415926535895435

Diff for: examples/rosetta/entropy.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.846439344671015
1+
1.8464393446710154

Diff for: examples/rosetta/fivenum.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
[36.0 40.0 7.0 39.0 41.0 15.0] ->
55
[7.0 15.0 37.5 40.0 41.0]
66

7-
[0.14082834 0.0974879 1.73131507 0.87636009 -1.95059594 0.7343855500000001 -0.03035726 1.4667597 -0.74621349 -0.72588772 0.6390516000000001 0.61501527 -0.9898378 -1.00447874 -0.62759469 0.66206163 1.04312009 -0.10305385 0.75775634 0.32566578] ->
8-
[-1.95059594 -0.676741205 0.23324706 0.746070945 1.73131507]
7+
[0.14082834 0.0974879 1.73131507 0.87636009 -1.95059594 0.73438555 -0.03035726 1.4667597 -0.74621349 -0.72588772 0.6390516 0.61501527 -0.9898378 -1.00447874 -0.62759469 0.66206163 1.04312009 -0.10305385 0.75775634 0.32566578] ->
8+
[-1.95059594 -0.676741205 0.23324706 0.746070945 1.73131507]

Diff for: examples/rosetta/haversine formula.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2887.259950607111
1+
2887.2599506071106

Diff for: examples/rosetta/kahan summation.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Sum of 1.0, epsilon and -epsilon for epsilon: 1.110223024625157e-16
1+
Sum of 1.0, epsilon and -epsilon for epsilon: 1.1102230246251565e-16
22
Is result equal to 1.0?
33
- simple addition: false
44
- using Kahan sum: true

Diff for: examples/rosetta/nth root.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
2.024397458499885
2-
1.453198460282268
2+
1.4531984602822678
33
2.23606797749979

Diff for: examples/rosetta/perlin noise.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1369199587840001
1+
0.13691995878400012

Diff for: examples/rosetta/problem of apollonius.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
2.0 2.1 3.9
2-
2.0 0.8333333333333333 1.166666666666667
2+
2.0 0.8333333333333333 1.1666666666666667

Diff for: examples/rosetta/real constants and functions.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Euler: 2.718281828459045
22
Pi: 3.141592653589793
3-
sqrt 2.0: 1.414213562373095
3+
sqrt 2.0: 1.4142135623730951
44
ln 100: 4.605170185988092
55
log(10) 100: 2.0
6-
exp 3: 20.08553692318767
6+
exp 3: 20.085536923187668
77
abs -1: 1
88
floor 23.536: 23
99
ceil 23.536: 24

Diff for: examples/rosetta/sum of a series.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.643934566681561
1+
1.6439345666815615

Diff for: examples/rosetta/temperature conversion.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[celcius:-173.15 fahrenheit:-279.67 rankine:180.0]
1+
[celcius:-173.14999999999998 fahrenheit:-279.67 rankine:180.0]

Diff for: src/extras/gmp.nim

+5-8
Original file line numberDiff line numberDiff line change
@@ -798,14 +798,11 @@ func mpz_xor*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc.}
798798
{.pop.}
799799

800800
#=======================================
801-
# Methods
801+
# Destructors
802802
#=======================================
803803

804-
func finalizeInt*(z: ref mpz_t) =
805-
mpz_clear(z[])
804+
proc `=destroy`*(x: mm_mpz_struct) =
805+
mpz_clear(addr x)
806806

807-
# func finalizeFloat*(z: ref mpf_t) =
808-
# mpf_clear(z[])
809-
810-
func finalizeRat*(z: ref mpq_t) =
811-
mpq_clear(z[])
807+
proc `=destroy`*(x: mm_mpq_struct) =
808+
mpq_clear(addr x)

Diff for: src/extras/mpfr.nim

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type
3939

4040
type
4141
mpfr* = mm_mpfr_struct
42+
mpfr_ptr* = ptr mm_mpfr_struct
4243

4344
#=======================================
4445
# Constants
@@ -59,6 +60,7 @@ const
5960

6061
func mpfr_get_version*(): cstring {.importc.}
6162

63+
func mpfr_clear*(a: mpfr_ptr) {.importc.}
6264
func mpfr_clear*(a: var mpfr) {.importc.}
6365
func mpfr_init*(a: var mpfr) {.importc.}
6466
func mpfr_set*(a: var mpfr, b: mpfr, c: mpfr_rnd_t) {.importc.}
@@ -96,8 +98,8 @@ func mpfr_pow_z*(a: var mpfr, b: mpfr, c: mpz_t, d: mpfr_rnd_t) {.importc.}
9698
{.pop.}
9799

98100
#=======================================
99-
# Methods
101+
# Destructors
100102
#=======================================
101103

102-
func finalizeFloat*(z: ref mpfr) =
103-
mpfr_clear(z[])
104+
proc `=destroy`*(x: mm_mpfr_struct) =
105+
mpfr_clear(addr x)

Diff for: src/helpers/bignums.nim

+23-23
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ func newInt*(x: culong): Int =
9292
# Warning: A custom '=destroy' hook which takes a 'var T' parameter is deprecated; it should take a 'T' parameter [Deprecated]
9393
# ```
9494
# labels: 3rd-party, enhancement
95-
new(result, finalizeInt)
95+
result = Int()
9696
mpz_init_set_ui(result[], x)
9797

9898
func newInt*(x: int = 0): Int =
99-
new(result, finalizeInt)
99+
result = Int()
100100
when isLLP64():
101101
if x.fitsLLP64Long:
102102
mpz_init_set_si(result[], x.clong)
@@ -110,57 +110,57 @@ func newInt*(x: int = 0): Int =
110110
mpz_init_set_si(result[], x.clong)
111111

112112
func newInt*(x: Float): Int =
113-
new(result,finalizeInt)
113+
result = Int()
114114
mpz_init(result[])
115115
mpz_set_d(result[], mpfr_get_d(x[], MPFR_RNDN))
116116

117117
func newInt*(s: string, base: cint = 10): Int =
118118
validBase(base)
119-
new(result, finalizeInt)
119+
result = Int()
120120
if mpz_init_set_str(result[], s, base) == -1:
121121
raise newException(ValueError, "String not in correct base")
122122

123123
func newFloat*(x: float): Float =
124-
new(result, finalizeFloat)
124+
result = Float()
125125
mpfr_init(result[])
126126
mpfr_set_d(result[], x, MPFR_RNDN)
127127

128128
func newFloat*(x: culong): Float =
129-
new(result, finalizeFloat)
129+
result = Float()
130130
mpfr_init(result[])
131131
mpfr_set_ui(result[], x, MPFR_RNDN)
132132

133133
func newFloat*(x: int = 0): Float =
134-
new(result, finalizeFloat)
134+
result = Float()
135135
mpfr_init(result[])
136136
mpfr_set_si(result[], x.clong, MPFR_RNDN)
137137

138138
func newFloat*(x: Int): Float =
139-
new(result,finalizeFloat)
139+
result = Float()
140140
mpfr_init(result[])
141141
mpfr_set_z(result[], x[], MPFR_RNDN)
142142

143143
func newFloat*(s: string, base: cint = 10): Float =
144144
validBase(base)
145-
new(result, finalizeFloat)
145+
result = Float()
146146
mpfr_init(result[])
147147
if mpfr_set_str(result[], s, base, MPFR_RNDN) == -1:
148148
raise newException(ValueError, "String not in correct base")
149149

150150
func newRat*(x: culong): Rat =
151-
new(result, finalizeRat)
151+
result = Rat()
152152
mpq_init(result[])
153153
mpq_set_ui(result[], x, 1)
154154
canonicalize(result)
155155

156156
func newRat*(x, y: culong): Rat =
157-
new(result,finalizeRat)
157+
result = Rat()
158158
mpq_init(result[])
159159
mpq_set_ui(result[], x, y)
160160
canonicalize(result)
161161

162162
func newRat*(x: int = 0): Rat =
163-
new(result, finalizeRat)
163+
result = Rat()
164164
mpq_init(result[])
165165
when isLLP64():
166166
if x.fitsLLP64Long:
@@ -176,7 +176,7 @@ func newRat*(x: int = 0): Rat =
176176
canonicalize(result)
177177

178178
func newRat*(x, y: int): Rat =
179-
new(result, finalizeRat)
179+
result = Rat()
180180
mpq_init(result[])
181181
when isLLP64():
182182
var nref = mpq_numref(result[])
@@ -205,27 +205,27 @@ func newRat*(x, y: int): Rat =
205205
canonicalize(result)
206206

207207
func newRat*(x, y: Int): Rat =
208-
new(result,finalizeRat)
208+
result = Rat()
209209
mpq_init(result[])
210210
mpq_set_num(result[], x[])
211211
mpq_set_den(result[], y[])
212212
canonicalize(result)
213213

214214
func newRat*(x: float): Rat =
215-
new(result,finalizeRat)
215+
result = Rat()
216216
mpq_init(result[])
217217
mpq_set_d(result[], x)
218218
canonicalize(result)
219219

220220
func newRat*(x: Int): Rat =
221-
new(result,finalizeRat)
221+
result = Rat()
222222
mpq_init(result[])
223223
mpq_set_z(result[], x[])
224224
canonicalize(result)
225225

226226
func newRat*(s: string, base: cint = 10): Rat =
227227
validBase(base)
228-
new(result, finalizeRat)
228+
result = Rat()
229229
mpq_init(result[])
230230
if mpq_set_str(result[], s, base) == -1:
231231
raise newException(ValueError, "String not in correct base")
@@ -236,17 +236,17 @@ func newRat*(s: string, base: cint = 10): Rat =
236236
#=======================================
237237

238238
func copyInt*(x: Int): Int =
239-
new(result, finalizeInt)
239+
result = Int()
240240
mpz_init(result[])
241241
mpz_set(result[], x[])
242242

243243
func copyFloat*(x: Float): Float =
244-
new(result,finalizeFloat)
244+
result = Float()
245245
mpfr_init(result[])
246246
mpfr_set(result[], x[], MPFR_RNDN)
247247

248248
func copyRat*(x: Rat): Rat =
249-
new(result,finalizeRat)
249+
result = Rat()
250250
mpq_init(result[])
251251
mpq_set(result[], x[])
252252

@@ -1173,12 +1173,12 @@ func nextPrime*(x: Int): Int =
11731173

11741174
func clear*(z: Int) {.inline.} =
11751175
GCunref(z)
1176-
finalizeInt(z)
1176+
mpz_clear(z[])
11771177

11781178
func clear*(z: Float) {.inline.} =
11791179
GCunref(z)
1180-
finalizeFloat(z)
1180+
mpfr_clear(z[])
11811181

11821182
func clear*(z: Rat) {.inline.} =
11831183
GCunref(z)
1184-
finalizeRat(z)
1184+
mpq_clear(z[])

0 commit comments

Comments
 (0)