User and Reference Guide for the Intel® C++ Compiler 14.0

Overview: Intel's Numeric String Conversion Library

Intel's Numeric String Conversion Library, libistrconv, provides a collection of routines for converting between ASCII strings and C data types, which are optimized for performance. The istrconv.h header file declares prototypes for the library functions.

You can link the libistrconv library as a static or shared library on Linux* and OS X* platforms. On Windows* platforms, you must link libistrconv as a static library only.

Using Intel's Numeric String Conversion Library

To use the libistrconv library, include the header file, istrconv.h, in your program.

Consider the following example conv.c file that illustrates how to use the library to convert between string and floating-point data type.

// conv.c 
#include <stdio.h> 
#include <istrconv.h> 
#define LENGTH 20 

int main() {
 const char pi[] = "3.14159265358979323";
 char s[LENGTH];
 int prec;
 float fx;
 double dx;
 printf("PI: %s\n", pi);
 printf("single precision\n");
 fx = __IML_string_to_float(pi, NULL);
 prec = 6;
 __IML_float_to_string(s, LENGTH, prec, fx);
 printf("prec: %2d, val: %s\n", prec, s);
 printf("double-precision\n");
 dx = __IML_string_to_double(pi, NULL);
 prec = 15;
 __IML_double_to_string(s, LENGTH, prec, dx);
 printf("prec: %2d, val: %s\n", prec, s);	
 return 0; 
}

To compile the conv.c file on Linux* platforms, use the following command:

icc conv.c –libistrconv

To compile the conv.c file on OS X* platforms, use the following command:

icl conv.c –libistrconv
icc conv.c –libistrconv

To compile the conv.c file on Windows* platforms, use the following command:

icl conv.c libistrconv.lib

After you compile this example and run the program, you should get the following results:

PI: 3.14159265358979323 

single precision		
prec: 6, val: 3.14159 

double-precision		
prec: 15, val: 3.14159265358979

Submit feedback on this help topic