M500 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/m500.rb +104 -79
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2dc24579fe7c9767f59040551729b3ba6b218e1031e030337d7e2e291839361b
|
4
|
+
data.tar.gz: f57431bbd2ed5c261e44ab1a31ca41eb685531b11e0fac126714119c004d4fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f951a70a40917ee45ca1ae515a977c459c8e54f3f8f9fc50c0bca24bff3a9c6d7572adcda48afc0e872ce64334fa9901129e79950df3520b1596fbdceff174
|
7
|
+
data.tar.gz: 7abff1db81d08621b76323450d904f8b990015c7e3762dc4b9a266e17a446055c9cf57f8fb5bccb5e9cdcde12ef2b815ee5ecab0e2510c589b077ff5e15a4c49
|
data/lib/m500.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# M500.rb -
|
3
4
|
# $Release Version: 0.9 $
|
4
|
-
# $Revision: 1.
|
5
|
+
# $Revision: 1.48 $
|
5
6
|
# by mark ingram
|
6
7
|
#
|
8
|
+
# Ruby 2.4 depcrecated Fixnum and Bignum
|
9
|
+
# Attempt to use Integer instead
|
7
10
|
# --
|
8
11
|
#
|
9
12
|
#
|
@@ -114,7 +117,7 @@ class String
|
|
114
117
|
def is_R?
|
115
118
|
false
|
116
119
|
end
|
117
|
-
|
120
|
+
def to_N
|
118
121
|
re = /(^[0-9]+)/
|
119
122
|
md = re.match(self.to_s)
|
120
123
|
t = emptySet
|
@@ -135,7 +138,7 @@ class String
|
|
135
138
|
def to_Q
|
136
139
|
re = /(-?[0-9]+)\/([0-9]+)/
|
137
140
|
md = re.match(self.to_s)
|
138
|
-
ret =
|
141
|
+
ret = emptySet
|
139
142
|
if md then
|
140
143
|
t = 1
|
141
144
|
Natural(md[2].to_i).kind_of?(EmptySetClass) ? ret = infinity : ret = Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i))
|
@@ -321,6 +324,7 @@ class Numeric
|
|
321
324
|
end
|
322
325
|
end
|
323
326
|
end
|
327
|
+
=begin
|
324
328
|
class Fixnum
|
325
329
|
include SGML
|
326
330
|
def to_sgml
|
@@ -373,10 +377,11 @@ class Fixnum
|
|
373
377
|
naught
|
374
378
|
end
|
375
379
|
end
|
376
|
-
|
380
|
+
=end
|
381
|
+
class Integer
|
377
382
|
include SGML
|
378
383
|
def to_sgml
|
379
|
-
"<mn #{sgml_id}class='
|
384
|
+
"<mn #{sgml_id}class='integer'>#{self.to_s}</mn>"
|
380
385
|
end
|
381
386
|
unless defined? Complex
|
382
387
|
alias power! **
|
@@ -400,13 +405,13 @@ class Bignum
|
|
400
405
|
self === 0 ? true : false
|
401
406
|
end
|
402
407
|
def to_N
|
403
|
-
self
|
408
|
+
self > 0 ? Natural(self) : emptySet
|
404
409
|
end
|
405
410
|
def to_N0
|
406
|
-
self
|
411
|
+
self >= 0 ? Counting(self) : emptySet
|
407
412
|
end
|
408
413
|
def to_Z
|
409
|
-
Zahlen(self)
|
414
|
+
Zahlen(self)
|
410
415
|
end
|
411
416
|
def to_Frac
|
412
417
|
Fraction(self,Quotient(1,1))
|
@@ -498,6 +503,7 @@ class Rational
|
|
498
503
|
end
|
499
504
|
end
|
500
505
|
class ST<Numeric
|
506
|
+
=begin
|
501
507
|
def initialize(a,b=0,c='t') # a*(c) + b
|
502
508
|
if a.kind_of?(String)
|
503
509
|
regex = /(\d+[a-z])*(\+)?(\d+)?/
|
@@ -552,6 +558,7 @@ class ST<Numeric
|
|
552
558
|
def inspect
|
553
559
|
"'#{@a.at(0)}#{@a.at(2)}+#{@a.at(1)}'.to_ST"
|
554
560
|
end
|
561
|
+
=end
|
555
562
|
end
|
556
563
|
def naught
|
557
564
|
NaughtClass.new!
|
@@ -574,7 +581,7 @@ def Natural(a)
|
|
574
581
|
infinity
|
575
582
|
elsif (a.kind_of?(String))
|
576
583
|
Natural.new!(a.to_i)
|
577
|
-
elsif (a.kind_of?(Fixnum) && a >= 1) or (a.kind_of?(Bignum) && a >= 1)
|
584
|
+
elsif (a.kind_of?(Integer) && a >= 1) #(a.kind_of?(Fixnum) && a >= 1) or (a.kind_of?(Bignum) && a >= 1)
|
578
585
|
Natural.new!(a)
|
579
586
|
elsif a.kind_of?(Numeric)
|
580
587
|
a.send :to_N
|
@@ -583,7 +590,7 @@ def Natural(a)
|
|
583
590
|
end
|
584
591
|
end
|
585
592
|
def Counting(a)
|
586
|
-
if (a.kind_of?(Fixnum) && a >= 0) or (a.kind_of?(Bignum) && a >= 0)
|
593
|
+
if (a.kind_of?(Integer) && a >= 0) #(a.kind_of?(Fixnum) && a >= 0) or (a.kind_of?(Bignum) && a >= 0)
|
587
594
|
Counting.new!(a)
|
588
595
|
elsif (a.kind_of?(EmptySetClass))
|
589
596
|
emptySet
|
@@ -596,20 +603,18 @@ def Counting(a)
|
|
596
603
|
elsif a.kind_of?(Numeric)
|
597
604
|
a.send :to_N0
|
598
605
|
else
|
599
|
-
|
606
|
+
emptySet
|
600
607
|
end
|
601
608
|
end
|
602
609
|
def Zahlen(a)
|
603
|
-
if a.kind_of?(
|
604
|
-
|
610
|
+
if a.kind_of?(Integer)
|
611
|
+
Zahlen.new!(a)
|
605
612
|
elsif (a.kind_of?(EmptySetClass))
|
606
613
|
emptySet
|
607
614
|
elsif (a.kind_of?(NaughtClass))
|
608
615
|
Zahlen.new!(0)
|
609
616
|
elsif (a.kind_of?(InfinityClass))
|
610
617
|
infinity
|
611
|
-
elsif a.kind_of?(Fixnum) or a.kind_of?(Bignum)
|
612
|
-
Zahlen.new!(a)
|
613
618
|
elsif a.kind_of?(Numeric)
|
614
619
|
a.send :to_Z
|
615
620
|
else
|
@@ -644,11 +649,7 @@ def Quotient(a,b=1)
|
|
644
649
|
elsif b.kind_of?(Quotient) && a == 1
|
645
650
|
Quotient.new!(b.denominator,b.numerator)
|
646
651
|
elsif Zahlen(a).kind_of?(Numeric) and Natural(b).kind_of?(Numeric)
|
647
|
-
unless a == b
|
648
|
-
Quotient.new!(Zahlen(a),Natural(b))
|
649
|
-
else
|
650
652
|
Quotient.new!(Zahlen(a),Natural(b))
|
651
|
-
end
|
652
653
|
elsif a.kind_of?(Quotient) && b.kind_of?(Quotient)
|
653
654
|
return a/b
|
654
655
|
elsif a.kind_of?(Numeric)
|
@@ -706,7 +707,7 @@ def Decimal(a,b=nil,c='0',d=0,e=1)
|
|
706
707
|
infinity
|
707
708
|
elsif a.kind_of?(String)
|
708
709
|
a.to_Dec
|
709
|
-
elsif (a.kind_of?(Fixnum) or a.kind_of?(Bignum)) and (b.kind_of?(Fixnum) or b.kind_of?(Bignum))
|
710
|
+
elsif a.kind_of?(Integer) #(a.kind_of?(Fixnum) or a.kind_of?(Bignum)) and (b.kind_of?(Fixnum) or b.kind_of?(Bignum))
|
710
711
|
if e<0 then
|
711
712
|
Decimal.new!(a,b,c,d,-1)
|
712
713
|
else
|
@@ -718,7 +719,7 @@ def Decimal(a,b=nil,c='0',d=0,e=1)
|
|
718
719
|
Decimal.new!(0,b,c,d,1)
|
719
720
|
end
|
720
721
|
end
|
721
|
-
elsif (a.kind_of?(Fixnum) or a.kind_of?(Bignum)) and b.nil?
|
722
|
+
elsif (a.kind_of?(Integer) and b.nil?) #(a.kind_of?(Fixnum) or a.kind_of?(Bignum)) and b.nil?
|
722
723
|
if e<0 then
|
723
724
|
Decimal.new!(a,b,c,d,-1)
|
724
725
|
else
|
@@ -746,7 +747,7 @@ def Kettenbruch(a,b='',c=1,leicht=true)
|
|
746
747
|
a.to_K
|
747
748
|
elsif a.kind_of?(Proc)
|
748
749
|
a
|
749
|
-
elsif (a.kind_of?(Fixnum) or a.kind_of?(Bignum)) and b.kind_of?(String)
|
750
|
+
elsif (a.kind_of?(Integer) and b.kind_of?(String)) # (a.kind_of?(Fixnum) or a.kind_of?(Bignum)) and b.kind_of?(String)
|
750
751
|
if (a>0 and c<0) or (a<0 and c>0) then
|
751
752
|
Kettenbruch.new!(a,b,-1)
|
752
753
|
else
|
@@ -784,7 +785,7 @@ class Natural < Numeric
|
|
784
785
|
end
|
785
786
|
private_class_method :new
|
786
787
|
def initialize(a)
|
787
|
-
if (a.kind_of?(Fixnum) && a >= 1) or (a.kind_of?(Bignum) && a >= 1)
|
788
|
+
if (a.kind_of?(Integer) && a >= 1) #(a.kind_of?(Fixnum) && a >= 1) or (a.kind_of?(Bignum) && a >= 1)
|
788
789
|
@a = a
|
789
790
|
else
|
790
791
|
emptySet
|
@@ -792,7 +793,7 @@ class Natural < Numeric
|
|
792
793
|
end
|
793
794
|
private :initialize
|
794
795
|
def + (a)
|
795
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
796
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer)#a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
796
797
|
Natural(self.to_i + a.to_i)
|
797
798
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass) or a.kind_of?(NilClass)
|
798
799
|
self
|
@@ -806,7 +807,7 @@ class Natural < Numeric
|
|
806
807
|
end
|
807
808
|
end
|
808
809
|
def - (a)
|
809
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
810
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) # a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
810
811
|
z = @a.to_i - a.to_i
|
811
812
|
z <= 0 ? emptySet : Natural(z)
|
812
813
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
|
@@ -819,7 +820,7 @@ class Natural < Numeric
|
|
819
820
|
end
|
820
821
|
end
|
821
822
|
def * (a)
|
822
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
823
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
823
824
|
Natural(@a * a.to_i)
|
824
825
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
|
825
826
|
naught
|
@@ -831,7 +832,7 @@ class Natural < Numeric
|
|
831
832
|
end
|
832
833
|
end
|
833
834
|
def / (a)
|
834
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
835
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
835
836
|
Natural(self.to_i / a.to_i)
|
836
837
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
|
837
838
|
infinity
|
@@ -841,7 +842,7 @@ class Natural < Numeric
|
|
841
842
|
end
|
842
843
|
end
|
843
844
|
def ** (a)
|
844
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
845
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
845
846
|
Natural(self.to_i ** a.to_i)
|
846
847
|
else
|
847
848
|
x, y = a.coerce(self)
|
@@ -873,7 +874,7 @@ class Natural < Numeric
|
|
873
874
|
self.to_i <=> other.to_i
|
874
875
|
end
|
875
876
|
def coerce(other)
|
876
|
-
if Fixnum === other or Bignum === other
|
877
|
+
if Integer === other #Fixnum === other or Bignum === other
|
877
878
|
other <= 0 ? [emptySet,emptySet] : [other.to_N,self]
|
878
879
|
elsif Natural === other or Counting === other or Zahlen === other
|
879
880
|
other <= 0 ? [emptySet,emptySet] : [other,self.to_Z]
|
@@ -894,11 +895,8 @@ class Natural < Numeric
|
|
894
895
|
def to_f
|
895
896
|
@a.to_f
|
896
897
|
end
|
897
|
-
def to_s!
|
898
|
-
"Natural(#{@a})"
|
899
|
-
end
|
900
898
|
def to_s
|
901
|
-
@a
|
899
|
+
"Natural(#{@a})"
|
902
900
|
end
|
903
901
|
def to_Q
|
904
902
|
Quotient(self, 1)
|
@@ -1012,11 +1010,11 @@ class Natural < Numeric
|
|
1012
1010
|
rz = 0
|
1013
1011
|
rx = []
|
1014
1012
|
r.each{|r4|
|
1015
|
-
rx <<
|
1013
|
+
rx << instance_eval("k=0;#{r4}") }
|
1016
1014
|
ry = rx.max
|
1017
1015
|
(0..m).to_a.each{|k|
|
1018
1016
|
r.each{|r4|
|
1019
|
-
r0 <<
|
1017
|
+
r0 << instance_eval("k=#{k};#{r4}")
|
1020
1018
|
}
|
1021
1019
|
rz= r0.max
|
1022
1020
|
res = res + r0
|
@@ -1081,11 +1079,8 @@ class NaughtClass
|
|
1081
1079
|
def to_f
|
1082
1080
|
0.0
|
1083
1081
|
end
|
1084
|
-
def to_s!
|
1085
|
-
"naught"
|
1086
|
-
end
|
1087
1082
|
def to_s
|
1088
|
-
"
|
1083
|
+
"naught"
|
1089
1084
|
end
|
1090
1085
|
def to_N
|
1091
1086
|
emptySet
|
@@ -1123,12 +1118,36 @@ class EmptySetClass < NaughtClass
|
|
1123
1118
|
def to_sgml
|
1124
1119
|
"<mn #{sgml_id}class='empty'>&empty</mn>"
|
1125
1120
|
end
|
1126
|
-
def to_s!
|
1127
|
-
"{}"
|
1128
|
-
end
|
1129
1121
|
def to_s
|
1130
1122
|
"\u2205".encode('utf-8')
|
1131
1123
|
end
|
1124
|
+
def to_N
|
1125
|
+
self.to_s
|
1126
|
+
end
|
1127
|
+
def to_N0
|
1128
|
+
self.to_s
|
1129
|
+
end
|
1130
|
+
def to_Z
|
1131
|
+
self.to_s
|
1132
|
+
end
|
1133
|
+
def to_Frac
|
1134
|
+
self.to_s
|
1135
|
+
end
|
1136
|
+
def to_Q
|
1137
|
+
self.to_s
|
1138
|
+
end
|
1139
|
+
def to_Dec
|
1140
|
+
self.to_s
|
1141
|
+
end
|
1142
|
+
def to_Sig
|
1143
|
+
self.to_s
|
1144
|
+
end
|
1145
|
+
def to_K
|
1146
|
+
self.to_s
|
1147
|
+
end
|
1148
|
+
def to_R
|
1149
|
+
self.to_s
|
1150
|
+
end
|
1132
1151
|
end
|
1133
1152
|
class NANClass < NaughtClass
|
1134
1153
|
include SGML
|
@@ -1172,9 +1191,6 @@ class InfinityClass
|
|
1172
1191
|
def to_f
|
1173
1192
|
nil
|
1174
1193
|
end
|
1175
|
-
def to_s!
|
1176
|
-
"infinity"
|
1177
|
-
end
|
1178
1194
|
def to_s
|
1179
1195
|
"\u221E".encode('utf-8')
|
1180
1196
|
end
|
@@ -1227,13 +1243,13 @@ class Counting < Natural
|
|
1227
1243
|
def initialize(a)
|
1228
1244
|
if (a.kind_of?(Counting))
|
1229
1245
|
@a = a.to_i
|
1230
|
-
elsif a.kind_of?(Fixnum) or a.kind_of?(Bignum)
|
1246
|
+
elsif a.kind_of?(Integer) #a.kind_of?(Fixnum) or a.kind_of?(Bignum)
|
1231
1247
|
@a = a
|
1232
1248
|
else
|
1233
1249
|
end
|
1234
1250
|
end
|
1235
1251
|
def + (a)
|
1236
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1252
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1237
1253
|
Counting(@a+a)
|
1238
1254
|
elsif a.kind_of?(Decimal) or a.kind_of?(Quotient) or a.kind_of?(Fraction)
|
1239
1255
|
Counting(@a+a.to_N0)
|
@@ -1247,7 +1263,7 @@ class Counting < Natural
|
|
1247
1263
|
end
|
1248
1264
|
end
|
1249
1265
|
def - (a)
|
1250
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1266
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1251
1267
|
@a-a < 0 ? emptySet : Counting(@a-a)
|
1252
1268
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
|
1253
1269
|
self
|
@@ -1260,7 +1276,7 @@ class Counting < Natural
|
|
1260
1276
|
end
|
1261
1277
|
def * (a)
|
1262
1278
|
t = nil
|
1263
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1279
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) # or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1264
1280
|
a < 0 ? emptySet : Counting(@a*a)
|
1265
1281
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
|
1266
1282
|
naught
|
@@ -1274,13 +1290,14 @@ class Counting < Natural
|
|
1274
1290
|
def / (a)
|
1275
1291
|
if (a.kind_of?(Counting) or a.kind_of?(Natural)) and (self.to_i%(a.to_i) == 0)
|
1276
1292
|
a < 0 ? emptySet : Counting(@a/ a)
|
1277
|
-
else
|
1278
|
-
|
1279
|
-
|
1293
|
+
else #not divisable so will not be whole number return emptySet
|
1294
|
+
#y < 0 ? emptySet : Counting(x/y)
|
1295
|
+
#x, y = a.coerce(self)
|
1296
|
+
return emptySet
|
1280
1297
|
end
|
1281
1298
|
end
|
1282
1299
|
def ** (a)
|
1283
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1300
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1284
1301
|
Counting(self.to_i ** a.to_i)
|
1285
1302
|
else
|
1286
1303
|
x, y = a.coerce(self)
|
@@ -1338,11 +1355,8 @@ class Counting < Natural
|
|
1338
1355
|
def to_f
|
1339
1356
|
@a.to_f
|
1340
1357
|
end
|
1341
|
-
def to_s!
|
1342
|
-
"Counting(#{@a})"
|
1343
|
-
end
|
1344
1358
|
def to_s
|
1345
|
-
@a
|
1359
|
+
"Counting(#{@a})"
|
1346
1360
|
end
|
1347
1361
|
def to_N
|
1348
1362
|
Natural(@a)
|
@@ -1386,13 +1400,13 @@ class Zahlen < Counting
|
|
1386
1400
|
def initialize(a)
|
1387
1401
|
if (a.kind_of?(Zahlen))
|
1388
1402
|
@a = a.to_i
|
1389
|
-
elsif a.kind_of?(Fixnum) or a.kind_of?(Bignum)
|
1403
|
+
elsif a.kind_of?(Integer) #a.kind_of?(Fixnum) or a.kind_of?(Bignum)
|
1390
1404
|
@a = a
|
1391
1405
|
else
|
1392
1406
|
end
|
1393
1407
|
end
|
1394
1408
|
def + (a)
|
1395
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1409
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1396
1410
|
Zahlen(self.to_i + a.to_i)
|
1397
1411
|
elsif a.kind_of?(Quotient) or a.kind_of?(Fraction)
|
1398
1412
|
a + Quotient(@a,1)
|
@@ -1406,7 +1420,7 @@ class Zahlen < Counting
|
|
1406
1420
|
end
|
1407
1421
|
end
|
1408
1422
|
def - (a)
|
1409
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1423
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) #a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1410
1424
|
Zahlen(self.to_i - a.to_i)
|
1411
1425
|
elsif a.kind_of?(Quotient) or a.kind_of?(Fraction)
|
1412
1426
|
a - Quotient(@a,1)
|
@@ -1420,7 +1434,7 @@ class Zahlen < Counting
|
|
1420
1434
|
end
|
1421
1435
|
end
|
1422
1436
|
def * (a)
|
1423
|
-
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1437
|
+
if a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer) # a.kind_of?(Bignum) or a.kind_of?(Fixnum)
|
1424
1438
|
Zahlen(self.to_i * a.to_i)
|
1425
1439
|
elsif a.kind_of?(Quotient) or a.kind_of?(Fraction)
|
1426
1440
|
a * Quotient(@a,1)
|
@@ -1434,7 +1448,7 @@ class Zahlen < Counting
|
|
1434
1448
|
end
|
1435
1449
|
end
|
1436
1450
|
def / (a)
|
1437
|
-
if (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum)) and self.to_i%(a.to_i) == 0
|
1451
|
+
if (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer)) and self.to_i%(a.to_i) == 0 #a.kind_of?(Bignum) or a.kind_of?(Fixnum)) and self.to_i%(a.to_i) == 0
|
1438
1452
|
Zahlen(self.to_i / a.to_i)
|
1439
1453
|
elsif a.kind_of?(Quotient) or a.kind_of?(Fraction)
|
1440
1454
|
self * Quotient(a.to_Q.denominator,a.to_Q.numerator)
|
@@ -1490,17 +1504,18 @@ class Zahlen < Counting
|
|
1490
1504
|
def to_f
|
1491
1505
|
@a.to_f
|
1492
1506
|
end
|
1493
|
-
def to_s!
|
1494
|
-
"Zahlen(#{@a})"
|
1495
|
-
end
|
1496
1507
|
def to_s
|
1497
|
-
@a
|
1508
|
+
"Zahlen(#{@a})"
|
1498
1509
|
end
|
1499
1510
|
def to_N
|
1500
1511
|
Natural(@a)
|
1501
1512
|
end
|
1513
|
+
def to_N0
|
1514
|
+
Counting(@a)
|
1515
|
+
end
|
1502
1516
|
def to_Z
|
1503
|
-
|
1517
|
+
self
|
1518
|
+
#Zahlen(@a)
|
1504
1519
|
end
|
1505
1520
|
def to_Frac
|
1506
1521
|
Fraction(@a,Quotient(0,1))
|
@@ -1550,6 +1565,9 @@ class Quotient < Numeric
|
|
1550
1565
|
b = -1*b if (a<0 and b<0)
|
1551
1566
|
@abs1 = 1
|
1552
1567
|
end
|
1568
|
+
if b==0 then
|
1569
|
+
# this should have been caught in def Quotient
|
1570
|
+
end
|
1553
1571
|
if a.kind_of?(Numeric) and b.kind_of?(Numeric)
|
1554
1572
|
a.kind_of?(Zahlen) ? @a = a : @a = Zahlen(a.to_i)
|
1555
1573
|
b.kind_of?(Natural) ? @b = b : @b = Natural(b.to_i)
|
@@ -1588,7 +1606,7 @@ class Quotient < Numeric
|
|
1588
1606
|
self
|
1589
1607
|
elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass)
|
1590
1608
|
infinity
|
1591
|
-
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum))
|
1609
|
+
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer)) # a.kind_of?(Bignum) or a.kind_of?(Fixnum))
|
1592
1610
|
self + Quotient(a, 1)
|
1593
1611
|
elsif a.kind_of?(Float)
|
1594
1612
|
Float(self) + a
|
@@ -1611,7 +1629,7 @@ class Quotient < Numeric
|
|
1611
1629
|
self
|
1612
1630
|
elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass)
|
1613
1631
|
infinity*(-1)
|
1614
|
-
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum))
|
1632
|
+
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer)) #a.kind_of?(Bignum) or a.kind_of?(Fixnum))
|
1615
1633
|
self - Quotient.new!(a, 1)
|
1616
1634
|
elsif a.kind_of?(Float)
|
1617
1635
|
Float(self) - a
|
@@ -1633,7 +1651,7 @@ class Quotient < Numeric
|
|
1633
1651
|
naught
|
1634
1652
|
elsif a.kind_of?(NANClass) or a.kind_of?(InfinityClass)
|
1635
1653
|
infinity
|
1636
|
-
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Bignum) or a.kind_of?(Fixnum))
|
1654
|
+
elsif (a.kind_of?(Zahlen) or a.kind_of?(Counting) or a.kind_of?(Natural) or a.kind_of?(Integer)) #a.kind_of?(Bignum) or a.kind_of?(Fixnum))
|
1637
1655
|
if a ==1 then
|
1638
1656
|
self
|
1639
1657
|
else
|
@@ -1754,7 +1772,7 @@ class Quotient < Numeric
|
|
1754
1772
|
def coerce(other)
|
1755
1773
|
if Natural === other or Counting === other or Zahlen === other
|
1756
1774
|
[Quotient(other,1),self]
|
1757
|
-
elsif Fixnum === other
|
1775
|
+
elsif Integer === other #Fixnum === other
|
1758
1776
|
[other, self.to_f]
|
1759
1777
|
else
|
1760
1778
|
[Float(other),self.to_f]
|
@@ -1770,6 +1788,7 @@ class Quotient < Numeric
|
|
1770
1788
|
@numerator.to_f/@denominator.to_f
|
1771
1789
|
end
|
1772
1790
|
def to_Frac
|
1791
|
+
Fraction(Zahlen(@numerator),Natural(@denominator))
|
1773
1792
|
self >= 0 ? Fraction(Zahlen(@numerator),Natural(@denominator),1) : Fraction(Zahlen(@numerator),Natural(@denominator),-1)
|
1774
1793
|
end
|
1775
1794
|
def to_Dec
|
@@ -1814,10 +1833,10 @@ class Quotient < Numeric
|
|
1814
1833
|
end
|
1815
1834
|
eval(ret)
|
1816
1835
|
end
|
1817
|
-
def to_s
|
1836
|
+
def to_s
|
1818
1837
|
"Quotient(#{(@a*@abs1).to_s},#{@b.to_s})"
|
1819
1838
|
end
|
1820
|
-
def
|
1839
|
+
def to_s_KM
|
1821
1840
|
if @b == 1
|
1822
1841
|
(@a*@abs1).to_s
|
1823
1842
|
else
|
@@ -1831,7 +1850,8 @@ class Quotient < Numeric
|
|
1831
1850
|
@numerator.hash ^ @denominator.hash ^ @abs.hash
|
1832
1851
|
end
|
1833
1852
|
end
|
1834
|
-
|
1853
|
+
|
1854
|
+
class Decimal < Numeric
|
1835
1855
|
def Decimal.new!(a,b,c=0,d=0,e=1)
|
1836
1856
|
new(a,b,c,d,e)
|
1837
1857
|
end
|
@@ -2181,7 +2201,7 @@ class Decimal < Numeric
|
|
2181
2201
|
t0 = ""
|
2182
2202
|
t0 = "0"*(@decimalExponent - 1) if @decimalExponent>0
|
2183
2203
|
t = "#{e}#{@integraldecimal}#{@@decimalSeparator}#{t0}#{@decimalfraction}#{@repetend.call}"
|
2184
|
-
|
2204
|
+
instance_eval("#{@@precision}.times{patt_succ(t)}")
|
2185
2205
|
return t
|
2186
2206
|
end
|
2187
2207
|
def inspect
|
@@ -2311,7 +2331,7 @@ class Fraction < Numeric #Mixed fraction
|
|
2311
2331
|
num = @properfraction.numerator * a.denominator
|
2312
2332
|
num_a = a.numerator * @properfraction.denominator
|
2313
2333
|
Fraction(num + num_a, @properfraction.denominator * a.denominator)
|
2314
|
-
elsif a.kind_of?(Integer)or a.kind_of?(Fixnum)
|
2334
|
+
elsif a.kind_of?(Integer) #or a.kind_of?(Fixnum)
|
2315
2335
|
a == 0 ? self: self + Fraction.new!(a, Quotient(0,1))
|
2316
2336
|
elsif a.kind_of?(Float)
|
2317
2337
|
Float(self) + a
|
@@ -2348,7 +2368,7 @@ class Fraction < Numeric #Mixed fraction
|
|
2348
2368
|
num = @properfraction.numerator * a.numerator
|
2349
2369
|
den = @properfraction.denominator * a.denominator
|
2350
2370
|
Fraction(num, den)
|
2351
|
-
elsif a.kind_of?(Integer) or a.kind_of?(Fixnum)
|
2371
|
+
elsif a.kind_of?(Integer) #or a.kind_of?(Fixnum)
|
2352
2372
|
if a == 0 then
|
2353
2373
|
0
|
2354
2374
|
elsif a == 1
|
@@ -2375,7 +2395,7 @@ class Fraction < Numeric #Mixed fraction
|
|
2375
2395
|
den = @properfraction.denominator * a.numerator
|
2376
2396
|
Fraction(num, den) unless a.numerator == 0
|
2377
2397
|
nan if a.numerator == 0
|
2378
|
-
elsif a.kind_of?(Integer) or a.kind_of?(Fixnum)
|
2398
|
+
elsif a.kind_of?(Integer) # or a.kind_of?(Fixnum)
|
2379
2399
|
self * Fraction.new!(1,a)
|
2380
2400
|
elsif a.kind_of?(NaughtClass) or a.kind_of?(EmptySetClass)
|
2381
2401
|
nan
|
@@ -2452,6 +2472,7 @@ class Fraction < Numeric #Mixed fraction
|
|
2452
2472
|
end
|
2453
2473
|
end
|
2454
2474
|
class Sigma<Numeric
|
2475
|
+
|
2455
2476
|
end
|
2456
2477
|
class Kettenbruch<Numeric
|
2457
2478
|
@@delta = 0
|
@@ -2923,6 +2944,7 @@ class Kettenbruch<Numeric
|
|
2923
2944
|
end
|
2924
2945
|
class Real< Numeric
|
2925
2946
|
include SGML
|
2947
|
+
@@reals={}
|
2926
2948
|
@@threebareqs = "\u2261"
|
2927
2949
|
def to_sgml
|
2928
2950
|
"<mn #{sgml_id}class='Real'>#{@a}</mn>"
|
@@ -2930,7 +2952,7 @@ class Real< Numeric
|
|
2930
2952
|
def Real.defines
|
2931
2953
|
@@threebareqs.encode('utf-8')
|
2932
2954
|
end
|
2933
|
-
def Real.new!(
|
2955
|
+
def Real.new!(a,b,label='')
|
2934
2956
|
if a.kind_of?(Real)
|
2935
2957
|
a
|
2936
2958
|
elsif a.kind_of?(Array)
|
@@ -2948,6 +2970,9 @@ class Real< Numeric
|
|
2948
2970
|
a
|
2949
2971
|
end
|
2950
2972
|
end
|
2973
|
+
def Real.s_add(a,b,label='')
|
2974
|
+
@@reals[label] = b
|
2975
|
+
end
|
2951
2976
|
def Real::epsilon(e)
|
2952
2977
|
#on epsilon change flag for dirty and recalculate
|
2953
2978
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: M500
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mark ingram
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: extended numbers
|
14
14
|
email:
|
15
15
|
- m.ingram@computer.org
|
16
16
|
executables: []
|
@@ -31,7 +31,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 2.4.0
|
35
35
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
@@ -39,8 +39,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
41
|
rubyforge_project: M500
|
42
|
-
rubygems_version: 2.
|
42
|
+
rubygems_version: 2.7.8
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
|
-
summary:
|
45
|
+
summary: support for Ruby 2.4 deprecation of Fixnum and Bignum
|
46
46
|
test_files: []
|