@@ -1957,6 +1957,39 @@ def test_frexp(self):
1957
1957
1.000000=1.000000*2^0
1958
1958
-1.000000=-1.000000*2^0''')
1959
1959
1960
+ def test_rounding(self):
1961
+ src = '''
1962
+ #include <stdio.h>
1963
+ #include <math.h>
1964
+
1965
+ int main()
1966
+ {
1967
+ printf("%.1f ", round(1.4));
1968
+ printf("%.1f ", round(1.6));
1969
+ printf("%.1f ", round(-1.4));
1970
+ printf("%.1f ", round(-1.6));
1971
+
1972
+ printf("%.1f ", round(1.5));
1973
+ printf("%.1f ", round(2.5));
1974
+ printf("%.1f ", round(-1.5));
1975
+ printf("%.1f ", round(-2.5));
1976
+
1977
+ printf("%ld ", lrint(1.4));
1978
+ printf("%ld ", lrint(1.6));
1979
+ printf("%ld ", lrint(-1.4));
1980
+ printf("%ld ", lrint(-1.6));
1981
+
1982
+ printf("%ld ", lrint(1.5));
1983
+ printf("%ld ", lrint(2.5));
1984
+ printf("%ld ", lrint(-1.5));
1985
+ printf("%ld ", lrint(-2.5));
1986
+
1987
+ return 0;
1988
+ }
1989
+ '''
1990
+ self.do_run(src, "1.0 2.0 -1.0 -2.0 2.0 3.0 -2.0 -3.0 "
1991
+ "1 2 -1 -2 2 2 -2 -2")
1992
+
1960
1993
def test_getgep(self):
1961
1994
# Generated code includes getelementptr (getelementptr, 0, 1), i.e., GEP as the first param to GEP
1962
1995
src = '''
0 commit comments