2014-02-03 23:03:13 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 INRIA
|
2017-10-25 11:07:14 +02:00
|
|
|
* 2017 Freie Universität Berlin
|
2014-02-03 23:03:13 +01:00
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
2014-02-03 23:03:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2017-10-25 11:07:14 +02:00
|
|
|
* @ingroup tests
|
2014-02-03 23:03:13 +01:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2017-10-25 11:07:14 +02:00
|
|
|
* @brief Float test application
|
2014-02-03 23:03:13 +01:00
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
2017-10-25 11:07:14 +02:00
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
2014-02-03 23:03:13 +01:00
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2014-01-10 16:21:35 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2014-07-15 18:47:39 +02:00
|
|
|
#include "board.h"
|
|
|
|
|
2020-07-29 12:23:45 +02:00
|
|
|
/* as default we run the test 1k times */
|
2017-10-25 11:07:14 +02:00
|
|
|
#ifndef TEST_ITER
|
2020-07-29 12:23:45 +02:00
|
|
|
#define TEST_ITER (1000UL)
|
2017-10-25 11:07:14 +02:00
|
|
|
#endif
|
|
|
|
|
2022-05-14 09:38:01 +02:00
|
|
|
#define FLOAT_STEP (0.1)
|
2017-10-25 11:07:14 +02:00
|
|
|
|
2014-01-10 16:21:35 +01:00
|
|
|
int main(void)
|
|
|
|
{
|
2014-07-25 08:17:06 +02:00
|
|
|
double x = 1234567.0 / 1024.0;
|
2014-01-25 11:29:35 +01:00
|
|
|
|
2019-10-23 21:14:15 +02:00
|
|
|
puts("Testing floating point arithmetic...\n");
|
2014-01-25 11:29:35 +01:00
|
|
|
|
2017-10-25 11:07:14 +02:00
|
|
|
for (unsigned long i = 0; i < TEST_ITER; i++) {
|
2022-05-14 09:38:01 +02:00
|
|
|
x += FLOAT_STEP;
|
2017-10-25 11:07:14 +02:00
|
|
|
double z = (x - floor(x));
|
|
|
|
if (z >= 1.0) {
|
|
|
|
puts("[FAILED]");
|
|
|
|
return 1;
|
2014-01-25 11:29:35 +01:00
|
|
|
}
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|
2017-10-25 11:07:14 +02:00
|
|
|
|
|
|
|
puts("[SUCCESS]");
|
|
|
|
|
|
|
|
return 0;
|
2014-01-10 16:21:35 +01:00
|
|
|
}
|