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.cc File Reference

#include "fastval2str.h"
#include <lib/numerics/num_math.h>

Include dependency graph for fastval2str.cc:

Include dependency graph

Go to the source code of this file.

Functions

template<typename T> char * _UInt2String (char *dest, T val, char base)
char * FastInt2String (char *dest, uint8 val, char base)
char * FastInt2String (char *dest, uint16 val, char base)
char * FastInt2String (char *dest, uint32 val, char base)
char * FastInt2String (char *dest, uint64 val, char base)
template<typename T, typename UT> char * _SInt2String (char *dest, T val, char base)
char * FastInt2String (char *dest, int8 val, char base)
char * FastInt2String (char *dest, int16 val, char base)
char * FastInt2String (char *dest, int32 val, char base)
char * FastInt2String (char *dest, int64 val, char base)
template<typename T> char * _Float2String (char *dest, T val)
char * FastFloat2String (char *dest, flt val)
char * FastFloat2String (char *dest, dbl val)

Variables

const char * _hexdig = "YZ0123456789abcdefGH"
const char * hexdig = _hexdig+2


Function Documentation

template<typename T>
char* _Float2String char *  dest,
val
[static]
 

Definition at line 147 of file fastval2str.cc.

References NUM::frexp(), and hexdig.

template<typename T, typename UT>
char* _SInt2String char *  dest,
val,
char  base
[inline, static]
 

Definition at line 123 of file fastval2str.cc.

template<typename T>
char* _UInt2String char *  dest,
val,
char  base
[static]
 

Definition at line 31 of file fastval2str.cc.

References Assert, hexdig, and uchar.

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.

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

Definition at line 143 of file fastval2str.cc.

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

Definition at line 141 of file fastval2str.cc.

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

Definition at line 139 of file fastval2str.cc.

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.

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

Definition at line 119 of file fastval2str.cc.

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

Definition at line 117 of file fastval2str.cc.

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

Definition at line 115 of file fastval2str.cc.

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

Definition at line 113 of file fastval2str.cc.


Variable Documentation

const char* _hexdig = "YZ0123456789abcdefGH" [static]
 

Definition at line 23 of file fastval2str.cc.

const char* hexdig = _hexdig+2 [static]
 

Definition at line 24 of file fastval2str.cc.

Referenced by _Float2String(), and _UInt2String().


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