TutRealToStr


Name

TutRealToStr — convert a real number to a string using the option Real_Number_Format

Synopsis

T_STR TutRealToStr(num) 
T_REAL8 num; 

Arguments

num — numeric value to be converted to a string

Return Values

String representation of num.

Diagnostics

None

Description

TutRealToStr is a convenience function that converts a numeric value to its string representation. TutRealToStr uses the value of the option Real_Number_Format and the standard C function sprintf. SmartSockets uses TutRealToStr to print real numbers.

Caution

The string returned by TutRealToStr is a static string managed internally by SmartSockets and should not be modified or deallocated. If a permanent copy of the string is needed, use T_STRDUP or TutStrDup to make one.

See Also

TutTimeNumToStr

Examples

This example prints two numbers using the format in the option Real_Number_Format:

TutOut("SmartSockets time is %s.\n", 
TutRealToStr(TutGetCurrentTime())); 
TutOut("Wall clock time is %s\n.", 
TutRealToStr(TutGetWallTime())); 

If the value of the option Real_Number_Format was %f, the output from the above fragment would be similar to this output:

SmartSockets time is 1.230000. 
Wall clock time is 769378847.976632. 

If the value of the option Real_Number_Format was %g, the output from the previous fragment would be similar to this output:

SmartSockets time is 1.23. 
Wall clock time is 7.69379e+08. 

Note that because the same string storage is reused by TutRealToStr, this code would not work:

TutOut("SmartSockets time is %s.\nWall clock time is %s\n", 
        TutRealToStr(TutGetCurrentTime()), 
        TutRealToStr(TutGetWallTime())); 

This code causes the same string value to be printed.


TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com