feisty meow concerns codebase  2.140
math_bits.cpp
Go to the documentation of this file.
1 /*****************************************************************************\
2 * *
3 * Name : mathematical operations group *
4 * Author : Chris Koeritz *
5 * *
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 \*****************************************************************************/
14 
15 #include "math_bits.h"
16 
17 #include <basis/astring.h>
18 
19 using namespace basis;
20 
21 namespace geometric {
22 
24 {
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.
33  } else break;
34  return to_return;
35 }
36 
38 {
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.
47  } else break;
48  return to_return;
49 }
50 
51 }
52 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
virtual void zap(int start, int end)
Deletes the characters between "start" and "end" inclusively.
Definition: astring.cpp:521
int length() const
Returns the current length of the string.
Definition: astring.cpp:132
Provides some fairly low-level math support.
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
Contains all of our objects for geometry and avoids name clashes.
Definition: angle.h:25
astring crop_non_numeric(const astring &input)
Eats the non-numeric characters from the front of "input".
Definition: math_bits.cpp:37
astring crop_numeric(const astring &input)
Eats the numeric characters from the front of "input".
Definition: math_bits.cpp:23