@@ -161,6 +161,18 @@ def test_fmpz():
161161 assert type (operator .index (f )) is int
162162 assert float (f ) == 2.0
163163 assert type (float (f )) is float
164+ assert round (f ) == 2
165+ assert type (round (f )) is flint .fmpz
166+ assert round (f , 1 ) == 2
167+ assert type (round (f , 1 )) is flint .fmpz
168+ assert round (f , - 1 ) == 0
169+ assert type (round (f , - 1 )) is flint .fmpz
170+ assert math .trunc (f ) == 2
171+ assert type (math .trunc (f )) is flint .fmpz
172+ assert math .floor (f ) == 2
173+ assert type (math .floor (f )) is flint .fmpz
174+ assert math .ceil (f ) == 2
175+ assert type (math .ceil (f )) is flint .fmpz
164176
165177 assert flint .fmpz (2 ) != []
166178 assert + flint .fmpz (0 ) == 0
@@ -811,21 +823,27 @@ def test_fmpq():
811823 assert Q (5 ,3 ).ceil () == flint .fmpz (2 )
812824 assert Q (- 5 ,3 ).ceil () == flint .fmpz (- 1 )
813825
814- assert int (Q (5 ,3 )) == flint .fmpz (1 )
826+ assert type (int (Q (5 ,3 ))) is int
827+ assert type (math .floor (Q (5 ,3 ))) is flint .fmpz
828+ assert type (math .ceil (Q (5 ,3 ))) is flint .fmpz
829+ assert type (math .trunc (Q (5 ,3 ))) is flint .fmpz
830+ assert type (round (Q (5 ,3 ))) is flint .fmpz
831+ assert type (round (Q (5 ,3 ))) is flint .fmpz
832+ assert type (round (Q (5 ,3 ), 0 )) is flint .fmpq
833+ assert type (round (Q (5 ,3 ), 1 )) is flint .fmpq
834+
835+ assert int (Q (5 ,3 )) == 1
815836 assert math .floor (Q (5 ,3 )) == flint .fmpz (1 )
816837 assert math .ceil (Q (5 ,3 )) == flint .fmpz (2 )
817838 assert math .trunc (Q (5 ,3 )) == flint .fmpz (1 )
818- assert round (Q (5 ,3 )) == 2
839+ assert round (Q (5 ,3 )) == flint . fmpz ( 2 )
819840
820841 assert int (Q (- 5 ,3 )) == flint .fmpz (- 1 )
821842 assert math .floor (Q (- 5 ,3 )) == flint .fmpz (- 2 )
822843 assert math .ceil (Q (- 5 ,3 )) == flint .fmpz (- 1 )
823844 assert math .trunc (Q (- 5 ,3 )) == flint .fmpz (- 1 )
824845 assert round (Q (- 5 ,3 )) == - 2
825846
826- assert type (round (Q (5 ,3 ))) is flint .fmpz
827- assert type (round (Q (5 ,3 ), 0 )) is flint .fmpq
828- assert type (round (Q (5 ,3 ), 1 )) is flint .fmpq
829847 assert round (Q (100 ,3 ), 2 ) == Q (3333 ,100 )
830848 assert round (Q (100 ,3 ), 0 ) == Q (33 ,1 )
831849 assert round (Q (100 ,3 ), - 1 ) == Q (30 ,1 )
0 commit comments