TutRealToStr convert a real number to a string using the option Real_Number_Format
num
numeric value to be converted to a string
String representation of num
.
None
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.
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.
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:
If the value of the option Real_Number_Format was %g
, the output from the previous fragment would be similar to this output:
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 |