xref: /aosp_15_r20/external/compiler-rt/test/builtins/Unit/truncdfsf2_test.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1 //===--------------- truncdfsf2_test.c - Test __truncdfsf2 ----------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file tests __truncdfsf2 for the compiler_rt library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include <stdio.h>
15 
16 #include "fp_test.h"
17 
18 float __truncdfsf2(double a);
19 
test__truncdfsf2(double a)20 int test__truncdfsf2(double a)
21 {
22     float actual = __truncdfsf2(a);
23     float expected = a;
24 
25     if (actual != expected) {
26         printf("error in test__truncdfsf2(%lf) = %f, "
27                "expected %f\n", a, actual, expected);
28         return 1;
29     }
30     return 0;
31 }
32 
main()33 int main()
34 {
35     if (test__truncdfsf2(340282366920938463463374607431768211456.0))
36         return 1;
37     return 0;
38 }
39