Files
kolibrios/programs/develop/ktcc/libc.obj/samples/math_test.c
T
ace-dentandBurer a4f3f3545a develop/ktcc: Post-SVN tidy (#425)
- Move source code from `trunk` into root directory.
- Update build files and ASM include paths. Add SPDX license header where appropriate.
- These changes also update the CI build files in `.gitea/workflows/`.
- Note: Line endings standardised from `CRLF` > `LF`, so best to view diffs with whitespace changes hidden.

(Work towards [#75](KolibriOS/kolibrios#75), point 3)

---------

Co-authored-by: Burer <burer@kolibrios.org>
Reviewed-on: KolibriOS/kolibrios#425
Reviewed-by: Mikhail Frolov <mixa.frolov2003@gmail.com>
Reviewed-by: Burer <burer@kolibrios.org>
Co-authored-by: Andrew <dent.ace@gmail.com>
Co-committed-by: Andrew <dent.ace@gmail.com>
2026-04-19 16:41:37 +00:00

42 lines
1.3 KiB
C

#include <math.h>
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 20; i++) {
printf("------------------------------------------------------\n");
// printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) );
// printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) );
// remainder of 5.3 / 2 is -0.700000
// remainder of 18.5 / 4.2 is 1.700000
printf("fmod of 5.3 / 2 is %f\n", fmod(5.3, 2));
printf("fmod of 18.5 / 4.2 is %f\n", fmod(18.5, 4.2));
// fmod of 5.3 / 2 is 1.300000
// fmod of 18.5 / 4.2 is 1.700000
double param, fractpart, intpart, result;
int n;
param = 3.14159265;
fractpart = modf(param, &intpart);
printf("%f = %f + %f \n", param, intpart, fractpart);
// 3.141593 = 3.000000 + 0.141593
param = 0.95;
n = 4;
result = ldexp(param, n);
printf("%f * 2^%d = %f\n", param, n, result);
// 0.950000 * 2^4 = 15.200000
param = 8.0;
result = frexp(param, &n);
printf("%f = %f * 2^%d\n", param, result, n);
// 8.000000 = 0.500000 * 2^4
param = 50;
result = frexp(param, &n);
printf("%f = %f * 2^%d\n", param, result, n);
}
}