Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/tst/testinstall/   (GAP Algebra Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 26 kB image not shown  

Quelle  float.tst   Sprache: unbekannt

 
Spracherkennung für: .tst vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

#@local neginf,posinf,r,nan,l,f,g,a,b,e1,e2
gap> START_TEST("float.tst");

# make sure we are testing the built-in machine floats
gap> SetFloats(IEEE754FLOAT);

# some special values we will use again later on
gap> posinf := 1.0/0.0;
inf
gap> neginf := -1.0/0.0;
-inf
gap> nan := 0.0/0.0;
nan

#
# Convert things to floats
#
gap> Float(3);
3.
gap> Float(-4);
-4.
gap> Float(2/3);
0.666667
gap> Float("-4");
-4.
gap> Float("4.1");
4.1
gap> Float("4.1e-1");
0.41
gap> Float(infinity);
inf
gap> Float(-infinity);
-inf

#
# Test converting rationals to machine floats
#
gap> f:=function(r, expected)
>   local testExp;
>   testExp:=function(actual, expected)
>     if (actual - expected) > FLOAT.EPSILON then
>       Error("expected ", expected, " but got ", actual);
>     fi;
>   end;
>   testExp(Float(r), expected);
>   testExp(Float(-r), -expected);
>   testExp(NewFloat(IsIEEE754FloatRep, r), expected);
>   testExp(NewFloat(IsIEEE754FloatRep, -r), -expected);
>   testExp(MakeFloat(0.0, r), expected);
>   testExp(MakeFloat(0.0, -r), -expected);
> end;;
gap> for a in [-1..1] do
>      for b in [-1..1] do
>        f( (10^309 + a) / (10^308 + b), 10.);
>      od;
>    od;
gap> for a in [-1..1] do
>      for b in [-1..1] do
>        f( (10^309 + a) / (10^309 + b), 1.);
>      od;
>    od;
gap> for e1 in [306..309] do for e2 in [306..309] do
>      for a in [-1..1] do for b in [-1..1] do
>        f( (10^e1 + a) / (10^e2 + b), 10.^(e1-e2));
>      od; od;
>    od; od;
gap> for e1 in [1020..1025] do for e2 in [1020..1025] do
>      for a in [-1..1] do for b in [-1..1] do
>        f( (2^e1 + a) / (2^e2 + b), 2.^(e1-e2));
>      od; od;
>    od; od;

#
# input floats directly
#
gap> 0.6;
0.6
gap> -0.7;
-0.7

#
# some arithmetic
#
gap> 355.0/113.0;
3.14159
gap> last = 355.0/113;
false
gap> 355.0/113.0-355/113;
0.
gap> 355.0/113.0 = 355.0/113;
false
gap> 355.0/113.0 < 355.0/113;
false
gap> 355.0/113.0 > 355.0/113;
true
gap> 355.0/113;
3.14159
gap> 355.0/113.0 - 355.0/113;
4.44089e-16
gap> 355/113.0 = 355.0/113.0;
false
gap> 355/113.0 - 355.0/113.0;
-4.44089e-16
gap> 355/113.0 - 355.0/113;
0.
gap> 355/113.0 = 355.0/113;
true

#
gap> 2.0^2;
4.
gap> 2.0^-2;
0.25
gap> 2.0^2.;
4.
gap> 2.0^-2.;
0.25

#
gap> LeftQuotient(1.02.0);
2.
gap> LeftQuotient(2.01.0);
0.5

#
# convert floats to ints
#
gap> Int(1.0);
1
gap> Int(1.5);
1
gap> Int(-1.0);
-1
gap> Int(-1.5);
-1
gap> Int(1.e22);
10000000000000000000000
gap> Int(-1.e22);
-10000000000000000000000
gap> Int(posinf);
Error, cannot convert float inf to integer
gap> Int(neginf);
Error, cannot convert float -inf to integer
gap> Int(nan);
Error, cannot convert float nan to integer

#
# convert floats to rationals
#
gap> Rat(355.0/113.0);
355/113
gap> Rat(0.5);
1/2
gap> Rat(0.0);
0
gap> Rat(posinf);
Error, cannot convert float inf to rational
gap> Rat(neginf);
Error, cannot convert float -inf to rational
gap> Rat(nan);
Error, cannot convert float nan to rational

#
# Print / View / Display for floats
#
gap> l := [ 0.0, -0.01.0, Sqrt(2.0), posinf, neginf, nan ];
0., -0., 1., 1.41421, inf, -inf, nan ]
gap> ViewObj(l); Print("\n");
0., -0., 1., 1.41421, inf, -inf, nan ]
gap> PrintObj(l); Print("\n");
0., -0., 1., 1.414213562373095, inf, -inf, nan ]
gap> Display(l);
0., -0., 1., 1.414213562373095, inf, -inf, nan ]

#
#
#
gap> Sqrt(2.0);
1.41421
gap> MinimalPolynomial(Rationals,last);
-2*x_1^2+1
gap> r:=Rat("2.7182818");; r:=Rat(Float(String(NumeratorRat(r)))/Float(String(DenominatorRat(r))));
2683788193/987310511
gap> Float(String(NumeratorRat(r)))/Float(String(DenominatorRat(r)));
2.71828
gap> AbsoluteValue(Float("1")/Float("2"));
0.5
gap> AbsoluteValue(Float("-1")/Float("2"));
0.5
gap> AbsoluteValue(-Float("1")/Float("2"));
0.5
gap> AbsoluteValue(-Float("0"));
0.
gap> Float(List([1..100],n->1/Factorial(n)));
1., 0.50.1666670.04166670.008333330.001388890.000198413
  2.48016e-052.75573e-062.75573e-072.50521e-082.08768e-09
  1.6059e-101.14707e-117.64716e-134.77948e-142.81146e-15
  1.56192e-168.22064e-184.11032e-191.95729e-208.89679e-22
  3.86817e-231.61174e-246.44695e-262.4796e-279.18369e-29
  3.27989e-301.131e-313.76999e-331.21613e-343.80039e-361.15163e-37
  3.38716e-399.67759e-412.68822e-427.26546e-441.91196e-45
  4.90247e-471.22562e-482.98931e-507.11741e-521.65521e-53
  3.76184e-558.35965e-571.81732e-583.86663e-608.05548e-62
  1.64397e-633.28795e-656.44696e-671.2398e-682.33925e-70
  4.33194e-727.87625e-741.40647e-752.4675e-774.2543e-797.21068e-81
  1.20178e-821.97013e-843.17763e-865.04386e-887.88103e-90
  1.21247e-911.83707e-932.7419e-954.0322e-975.84377e-99
  8.34824e-1011.17581e-1021.63307e-1042.23708e-1063.02308e-108
  4.03077e-1105.30365e-1126.88785e-1148.83058e-1161.1178e-117
  1.39724e-1191.72499e-1212.10365e-1232.53452e-1253.01728e-127
  3.54974e-1294.12761e-1314.74438e-1335.39134e-1356.05769e-137
  6.73076e-1397.39644e-1418.03961e-1438.64474e-1459.19653e-147
  9.68056e-1491.00839e-1501.03958e-1521.0608e-1541.07151e-156
  1.07151e-158 ]
gap> 1.5e10;
1.5e+10
gap> -1.5e0;
-1.5
gap> 0.7e-10;
7.e-11
gap> -0.8e-0;
-0.8
gap> 1000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000000000.0;
1.e+125
gap> 1.5+1;
2.5
gap> last-1.6;
0.9
gap> last*2;
1.8
gap> last/2.0;
0.9
gap> Sqrt(last);
0.948683
gap> Log(last);
-0.0526803
gap> Exp(last);
0.948683
gap> last^2;
0.9

#
# some tests with infinity
#
gap> 1.0/0.0;
inf
gap> -1.0/0.0;
-inf
gap> List([posinf, neginf, nan, 0.01.0], IsPInfinity);
[ true, false, false, false, false ]
gap> List([posinf, neginf, nan, 0.01.0], IsNInfinity);
[ false, true, false, false, false ]
gap> -posinf = neginf;
true
gap> posinf = -neginf;
true
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

#
# test sign handling
#
gap> SignBit(posinf);
false
gap> SignFloat(posinf);
1
gap> SignBit(neginf);
true
gap> SignFloat(neginf);
-1
gap> SignBit(+0.0);
false
gap> SignFloat(+0.0);
0
gap> SignBit(-0.0);
true
gap> SignFloat(-0.0);
0
gap> SignBit(42.0);
false
gap> SignFloat(42.0);
1
gap> SignBit(-42.0);
true
gap> SignFloat(-42.0);
-1

# sign of NaN is machine specific; but we can still test whether
# SignBit and SignFloat return consistent results
gap> SignBit(nan) = (SignFloat(nan) = -1);
true
gap> SignBit(-nan) = (SignFloat(-nan) = -1);
true

#
# test float comparison
#

#
gap> EqFloat(1.01.1);
false
gap> EqFloat(1.01.0);
true
gap> EqFloat(0.0/0.0,0.0/0.0);
false
gap> EqFloat(0.0,0.0/0.0);
false

#
# float literals in the REPL
#
gap> 1.1;
1.1
gap> 1.1_;
1.1
gap> 1.1_l;
1.1
gap> 1.x1;
Syntax error: Badly formed number in stream:1
1.x1;
^^^
gap> 1.1xx;
Syntax error: Badly formed number in stream:1
1.1xx;
^^^^

# longer than 1023 chars
gap> 2.1111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111;
2.11111
gap> 2.1111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111_;
2.11111
gap> 2.1111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111_l;
2.11111

# The following is potentially correct, *if* there is a conversion handler for
# 'x' installed, which normally isn't the case.
gap> 1.1_x;
Error, Unknown float literal conversion 'x'
gap> 1.1x;
Error, failed to convert float literal
gap> 2.1111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111_x;
Error, Unknown float literal conversion 'x'
gap> 2.1111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111x;
Error, failed to convert float literal

#
# float literal expressions in functions
#

# eager literal
gap> f := {} -> 0.0_;; f();
0.
gap> f := {} -> 1.0_;; f();
1.
gap> f := {} -> 42.0_;; f();
42.
gap> Display(f);
function (  )
    return 42.0_;
end
gap> f := {} -> 42.0_l;; f();
42.
gap> Display(f);
function (  )
    return 42.0_l;
end
gap> f := {} -> 42.0_x;;
Error, Unknown float literal conversion 'x'
gap> f := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111111111111111111111111111111111111111111111111_;;
gap> f();
2.11111
gap> Display(f);
function (  )
    return 
     2.11111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111_;
end
gap> f := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111111111111111111111111111111111111111111111111_l;;
gap> f();
2.11111
gap> Display(f);
function (  )
    return 
     2.11111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111_l;
end
gap> f := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111111111111111111111111111111111111111111111111_x;;
Error, Unknown float literal conversion 'x'

# lazy literal
gap> g := {} -> 0.0;; g();   # special case 0.0
0.
gap> g := {} -> 1.0;; g();   # special case 1.1
1.
gap> g := {} -> 23.0;; g();  # generic case
23.
gap> Display(g);
function (  )
    return 23.0;
end
gap> g := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111111111111111111111111111111111111111111111111;;
gap> Display(g);
function (  )
    return 
     2.11111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111;
end
gap> g();
2.11111
gap> g := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111111111111111111111111111111111111111111111111l;;
gap> Display(g);
function (  )
    return 
     2.11111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111l;
end
gap> g();
fail
gap> g := {} -> 23.0x;; # this works, as we evaluate lazily
gap> g();
fail
gap> g := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111111111111111111111111111111111111111111111111x;;
gap> g();
fail

#
# test some cases in CheckForCommonFloat
#
gap> g := {} -> 0.0;; g();
0.
gap> g := {} -> 1.0;; g();
1.
gap> g := {} -> 1.01;; g();
1.01
gap> g := {} -> 0.012;; g();
0.012
gap> g := {} -> 0.01e1;; g();
0.1
gap> g := {} -> 0.01e2;; g();
1.
gap> g := {} -> 0.01e+02;; g();
1.
gap> g := {} -> 10.0e-2;; g();
0.1
gap> g := {} -> 10.0e-01;; g();
1.
gap> g := {} -> 1.0e0;; g();
1.
gap> g := {} -> 1.0e+0;; g();
1.
gap> g := {} -> 1.0e-0;; g();
1.
gap> g := {} -> 1.0e01;; g();
10.

#
#
#
gap> Cos(0.);
1.
gap> Sin(0.);
0.
gap> Tan(0.);
0.
gap> Sec(0.);
1.
gap> Csc(0.);
inf
gap> Cot(0.);
inf
gap> Acos(1.);
0.
gap> Asin(0.);
0.
gap> Atan(0.);
0.

#
gap> Cosh(0.);
1.
gap> Sinh(0.);
0.
gap> Tanh(0.);
0.
gap> Sech(0.);
1.
gap> Csch(0.);
inf
gap> Coth(0.);
inf
gap> Asinh(0.);
0.
gap> Acosh(0.);
nan
gap> Atanh(0.);
0.

#
gap> Log(1.);
0.
gap> Log2(1.);
0.
gap> Log10(1.);
0.
gap> Log1p(0.);
0.

#
gap> Exp(0.);
1.
gap> Exp2(0.);
1.
gap> Exp10(0.);
1.
gap> Expm1(0.);
0.

#
gap> CubeRoot(0.);
0.
gap> Square(0.);
0.

#
gap> FrExp(0.);
0., 0 ]
gap> LdExp(0.,0);
0.
gap> Norm(0.);
0.
gap> SinCos(0.);
0., 1. ]
gap> Erf(0.);
0.
gap> #Zeta(0.);     # TODO: not implemented for machine floats
gap> Gamma(1.);
1.

#
gap> Round(1.3);
1.
gap> Round(1.9);
2.
gap> Round(-1.9);
-2.
gap> Round(-1.3);
-1.

#
gap> Floor(1.3);
1.
gap> Floor(1.9);
1.
gap> Floor(-1.9);
-2.
gap> Floor(-1.3);
-2.

#
gap> Ceil(1.3);
2.
gap> Ceil(1.9);
2.
gap> Ceil(-1.9);
-1.
gap> Ceil(-1.3);
-1.

#
gap> Trunc(1.3);
1.
gap> Trunc(1.9);
1.
gap> Trunc(-1.9);
-1.
gap> Trunc(-1.3);
-1.

#
gap> Frac(1.3);
0.3
gap> Frac(1.9);
0.9
gap> Frac(-1.9);
0.1
gap> Frac(-1.3);
0.7

#
gap> AbsoluteValue(1.3);
1.3
gap> AbsoluteValue(1.9);
1.9
gap> AbsoluteValue(-1.9);
1.9
gap> AbsoluteValue(-1.3);
1.3

#
gap> Atan2(0.,0.);
0.
gap> Hypothenuse(3.,4.);
5.

#
gap> ComplexConjugate(1.3);
1.3

#
gap> Display(1.3);
1.3
gap> Display(-.4e6);
-400000.
gap> PrintObj(1.3); Print("Q\n");
1.3Q
gap> DisplayString(1.3);
"1.3\n"

#
gap> STOP_TEST("float.tst");

[Dauer der Verarbeitung: 0.15 Sekunden, vorverarbeitet 2026-06-12]