math_bits.cpp

Go to the documentation of this file.
00001 #ifndef MATH_BITS_IMPLEMENTATION_FILE
00002 #define MATH_BITS_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : mathematical operations group                                     *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "math_bits.h"
00019 
00020 #include <basis/istring.h>
00021 
00022 istring crop_numeric(const istring &input)
00023 {
00024   istring to_return(input);
00025   for (int i = 0; i < to_return.length(); i++)
00026     if ( ( (to_return[i] >= '0') && (to_return[i] <= '9') )
00027          || (to_return[i] == '.')
00028          || (to_return[i] == '+') || (to_return[i] == '-')
00029          || (to_return[i] == 'E') || (to_return[i] == 'e') ) {
00030       to_return.zap(i, i);  // remove non-useful character.
00031       i--;  // move backwards in loop.
00032     } else break;
00033   return to_return;
00034 }
00035 
00036 istring crop_non_numeric(const istring &input)
00037 {
00038   istring to_return(input);
00039   for (int i = 0; i < to_return.length(); i++)
00040     if ( ! ((to_return[i] >= '0') && (to_return[i] <= '9'))
00041          && (to_return[i] != '.')
00042          && (to_return[i] != '+') && (to_return[i] != '-')
00043          && (to_return[i] != 'E') && (to_return[i] != 'e') ) {
00044       to_return.zap(i, i);  // remove non-useful character.
00045       i--;  // move backwards in loop.
00046     } else break;
00047   return to_return;
00048 }
00049 
00050 
00051 #endif //MATH_BITS_IMPLEMENTATION_FILE
00052 

Generated on Fri Nov 28 04:29:14 2008 for HOOPLE Libraries by  doxygen 1.5.1