Skip to content

Commit

Permalink
Add missing methods for -infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson committed Nov 26, 2016
1 parent 9afb0fe commit bf72479
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/float.gi
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ BindGlobal("INSTALLFLOATCONSTRUCTORS", function(arg)
InstallMethod(NewFloat, [filter,IsInfinity], -1, function(filter,obj)
return Inverse(NewFloat(filter,0));
end);

InstallMethod(NewFloat, [filter,IsNegInfinity], -1, function(filter,obj)
return -Inverse(NewFloat(filter,0));
end);

InstallMethod(NewFloat, [filter,IsList], -1, function(filter,mantexp)
if mantexp[1]=0 then
Expand All @@ -132,6 +136,10 @@ BindGlobal("INSTALLFLOATCONSTRUCTORS", function(arg)
InstallMethod(MakeFloat, [filter,IsInfinity], -1, function(filter,obj)
return Inverse(MakeFloat(filter,0));
end);

InstallMethod(MakeFloat, [filter,IsNegInfinity], -1, function(filter,obj)
return -Inverse(MakeFloat(filter,0));
end);

InstallMethod(MakeFloat, [filter,IsList], -1, function(filter,mantexp)
if mantexp[1]=0 then
Expand Down
1 change: 1 addition & 0 deletions lib/string.gi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## This file contains functions for strings.
##

InstallOtherMethod(\+, "For two strings", [IsString, IsString], Concatenation);

#############################################################################
##
Expand Down
24 changes: 24 additions & 0 deletions tst/teststandard/float.tst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@ gap> Exp(last);
0.948683
gap> last^2;
0.9
gap> 1.0/0.0;
inf
gap> -1.0/0.0;
-inf
gap> -Float(infinity) = Float(-infinity);
true
gap> posinf := Float(infinity);
inf
gap> neginf := Float(-infinity);
-inf
gap> neginf < posinf;
true
gap> neginf <> posinf;
true
gap> neginf < 0.0;
true
gap> 0.0 < posinf;
true
gap> MakeFloat(1.0, infinity) = posinf;
true
gap> -MakeFloat(1.0, infinity) = neginf;
true
gap> MakeFloat(1.0, -infinity) = neginf;
true
gap> STOP_TEST( "float.tst", 280000);

#############################################################################
Expand Down

0 comments on commit bf72479

Please sign in to comment.