/* xls2xml: Converts from Microsoft Excel files to XML. Copyright 1999 Roberto Arturo Tena Sanchez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Roberto Arturo Tena Sanchez */ #include #include #include char * IEEEnumber2str (U8 * n, int double_precision) { char * rnumber; char snumber [500]; /* MAGIC NUMBER */ if (double_precision) { sprintf (snumber, "%f", _xls2xml_sreadF64 (n)); rnumber = malloc (strlen (snumber) + 1); test (rnumber != NULL, NULL); strcpy (rnumber, snumber); return rnumber; } else { fprintf (stderr, "IEEEnumber2str single precision not implemented yet\n"); return NULL; } } char * RKnumber2str (U8 * n) { F64 answer; U32 number; U32 temp[2]; char snumber [500]; /* MAGIC NUMBER */ char * rnumber; number = _xls2xml_sreadU32 (n); switch (number & 0x03) { case 0: /* IEEE */ temp[0] = 0; temp[1] = number & 0xfffffffc; answer = *( (F64*)temp ); verbose ("RK IEEE"); break; case 1: /* IEEEx100 */ temp[0] = 0; temp[1] = number & 0xfffffffc; answer = *( (F64*)temp ) / 100.0; verbose ("RK IEEEx100"); break; case 2: /* integer */ answer = (F64)(number >> 2); verbose ("RK integer"); break; case 3: /* integerx100 */ answer = (F64)(number >> 2) / 100.0; verbose ("RK integerx100"); break; } sprintf (snumber, "%f", answer); rnumber = malloc (strlen (snumber) + 1); test (rnumber != NULL, NULL); strcpy (rnumber, snumber); return rnumber; }