GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
trim_dec.c
Go to the documentation of this file.
1
/*!
2
* \file lib/gis/trim_dec.c
3
*
4
* \brief GIS Library - Trim string decimal functions.
5
*
6
* (C) 2001-2009 by the GRASS Development Team
7
*
8
* This program is free software under the GNU General Public License
9
* (>=v2). Read the file COPYING that comes with GRASS for details.
10
*
11
* \author Original author CERL
12
*/
13
14
#include <string.h>
15
#include <
grass/gis.h
>
16
17
/*!
18
* \brief Removes trailing zeros from decimal number.
19
*
20
* Example: 23.45000 would come back as 23.45
21
*
22
* \param[in,out] buf
23
*/
24
void
G_trim_decimal
(
char
*buf)
25
{
26
char
*mark;
27
28
/* don't trim e+20 into e+2 */
29
if
(strchr(buf,
'e'
) || strchr(buf,
'E'
))
30
return
;
31
32
/* find the . */
33
while
(*buf !=
'.'
)
34
if
(*buf++ == 0)
35
return
;
36
37
mark = buf;
38
while
(*++buf)
39
if
(*buf !=
'0'
)
40
mark = buf + 1;
41
*mark = 0;
42
}
gis.h
G_trim_decimal
void G_trim_decimal(char *buf)
Removes trailing zeros from decimal number.
Definition:
trim_dec.c:24
lib
gis
trim_dec.c
Generated on Thu Nov 21 2024 07:03:30 for GRASS GIS 8 Programmer's Manual by
1.9.1