Reverse of atof with LabTalk formatting options
string ftoa( double dVal, LPCSTR lpcszFmt = NULL )
formatted string
EX1
// This example demonstrates some of the Origin formats. void ftoa_ex1() { double d = PI; out_str(ftoa(d)); // Full precision out_str(ftoa(d, "*3")); // 3 significant digits d *= 1000; // Make integer portion bigger for next examples. out_str(ftoa(d, "S*6")); // 6 significant digits in scientific notation out_str(ftoa(d, "E.4")); // 4 decimal places in engineering notation // There is even support for date and time formats. LT_get_var("@D", &d); // Get current date and time as Julian value. out_str(ftoa(d)); // Julian value in full precision out_str(ftoa(d, "D1")); // Date in "weekday, month day, year" format out_str(ftoa(d, "D10")); // Date in "mm/dd/yyyy hh:mm:ss" format out_str(ftoa(d, "T5")); // Time in "hh:mm PM" format }
EX2
// This example demonstrates some of the C-Language formats. void ftoa_ex2() { double d = PI; out_str(ftoa(d, "%f")); // Full precision out_str(ftoa(d, "%.2f")); // 2 digits after decimal out_str(ftoa(d, "%E")); // Scientific notation // The following formats are for formatting integers // but can still be used with real values. d *= 100.0; // Make the integer portion bigger. out_str(ftoa(d, "%d")); // Decimal (base 10) out_str(ftoa(d, "%X")); // Hex (base 16) out_str(ftoa(d, "%o")); // Octal (base 8) }
atof
origin.h