1 /*****************************************************************************\
3 * Name : mathematical operations group *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 1996-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "math_bits.h"
17 #include <basis/astring.h>
19 using namespace basis;
23 astring crop_numeric(const astring &input)
25 astring to_return(input);
26 for (int i = 0; i < to_return.length(); i++)
27 if ( ( (to_return[i] >= '0') && (to_return[i] <= '9') )
28 || (to_return[i] == '.')
29 || (to_return[i] == '+') || (to_return[i] == '-')
30 || (to_return[i] == 'E') || (to_return[i] == 'e') ) {
31 to_return.zap(i, i); // remove non-useful character.
32 i--; // move backwards in loop.
37 astring crop_non_numeric(const astring &input)
39 astring to_return(input);
40 for (int i = 0; i < to_return.length(); i++)
41 if ( ! ((to_return[i] >= '0') && (to_return[i] <= '9'))
42 && (to_return[i] != '.')
43 && (to_return[i] != '+') && (to_return[i] != '-')
44 && (to_return[i] != 'E') && (to_return[i] != 'e') ) {
45 to_return.zap(i, i); // remove non-useful character.
46 i--; // move backwards in loop.