The lmp90100_evb sample included an implementation of double sqrt, and the on_off_level_lighting_vnd_app sample included an implementation of float sqrtf. Move that code into minimal libc instead of requiring applications to hand-roll their own version. Signed-off-by: Keith Packard <keithp@keithp.com>
24 lines
296 B
C
24 lines
296 B
C
/*
|
|
* Copyright (c) 2019 Vestas Wind Systems A/S
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <math.h>
|
|
|
|
double sqrt(double value)
|
|
{
|
|
double sqrt = value / 3;
|
|
int i;
|
|
|
|
if (value <= 0) {
|
|
return 0;
|
|
}
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
sqrt = (sqrt + value / sqrt) / 2;
|
|
}
|
|
|
|
return sqrt;
|
|
}
|