Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/lex/fastval2str.h File Reference

Fast integer / floating point tring writing routines. More...

#include <lib/sconfig.h>
#include <lib/serror.h>

Include dependency graph for fastval2str.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define _LIB_LEX_FASTVAL2STRING_H_   1


Detailed Description

Fast integer / floating point tring writing routines.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Functions to convert integer and floating point values into strings. These are just basic routines indended to be fast.

Definition in file fastval2str.h.


Define Documentation

#define _LIB_LEX_FASTVAL2STRING_H_   1
 

Definition at line 18 of file fastval2str.h.


Function Documentation

char* FastFloat2String char *  dest,
dbl  val
 

Definition at line 192 of file fastval2str.cc.

References dbl.

Referenced by VM::InstructionStorage::DumpInstruction().

char* FastFloat2String char *  dest,
flt  val
 

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
The floating point value will be emitted as a hexadecimal floating point value representing the complete prescision of a 4 or 8 byte floating point value, respectively. Trailing zeros are omitted.

NOTE that this is a dangerous function (dangerous for the sake of speed). The caller has to make sure that dest is long enough to hold the string. Fortunately, the limit is not very hard to predict: it is

  • 4+13+2+3 = 22 chars for a flt.
  • 4+6+2+2 = 14 chars for a dbl.
The result looks like "-0x.11111p-22".

Definition at line 190 of file fastval2str.cc.

References flt.

char* FastInt2String char *  dest,
uint64  val,
char  base = 16
 

Definition at line 119 of file fastval2str.cc.

References uint64.

Referenced by VM::NamespaceInfo::SymbolEntryB::CompleteName(), VM::ClassInfoIE::CompleteName(), and VM::InstructionStorage::DumpInstruction().

char* FastInt2String char *  dest,
uint32  val,
char  base = 16
 

Definition at line 117 of file fastval2str.cc.

References uint32.

char* FastInt2String char *  dest,
uint16  val,
char  base = 16
 

Definition at line 115 of file fastval2str.cc.

References uint16.

char* FastInt2String char *  dest,
uint8  val,
char  base = 16
 

Definition at line 113 of file fastval2str.cc.

References uint8.

char* FastInt2String char *  dest,
int64  val,
char  base = 16
 

Definition at line 143 of file fastval2str.cc.

References int64.

char* FastInt2String char *  dest,
int32  val,
char  base = 16
 

Definition at line 141 of file fastval2str.cc.

References int32.

char* FastInt2String char *  dest,
int16  val,
char  base = 16
 

Definition at line 139 of file fastval2str.cc.

References int16.

char* FastInt2String char *  dest,
int8  val,
char  base = 16
 

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
These functions will convert the intever val to a string written into *dest. The string will NOT be NUL-terminated and the returned pointer points to the location where to go on (e.g. by terminating with NUL).

The integer can be written in a base of 8, 10 or 16. For base 8, a zero (0) is prepended, for base 16, 0x is prepended.

NOTE that this is a dangerous function (dangerous for the sake of speed). The caller has to make sure that dest is long enough to hold the string. Fortunately, the limit is not very hard to predict; here is a table:

Integeroctaldecimalhex Integeroctaldecimalhex
uint8434 int8545
uint16756 int16867
uint32121010 int32131111
uint64232018 int64242019

Generally, the space consumption is

  • ceil(sizeof(T)*8/log2(base)) for the digits
  • +1 for a sign
  • +1 for octal and +2 for hexadecimal prefix
THESE FUNCTIONS ARE FAST BUT DANGEROUS. USE WITH CARE. IF IN DOUBT, USE SOMETHING ELSE. THEY ARE PRIMARILY FOR INTERNAL USE BY HIGHER-LEVEL OUTPUT ROUTINES.

Definition at line 137 of file fastval2str.cc.

References int8.


Generated on Sat Feb 19 22:33:59 2005 for Ray by doxygen 1.3.5