XSLPformatvalue
XSLPformatvalue |
Purpose
Format a double-precision value in the style of Xpress NonLinear
Synopsis
int XPRS_CC XSLPformatvalue(double dValue, char *Buffer);
Arguments
|
dValue
|
Double precision value to be formatted.
|
|
Buffer
|
Character buffer to hold the formatted result. The result will never be more than 15 characters in length including the terminating null character. |
Example
The following example formats the powers of 16 from -6 to +6 and prints the results:
int i;
double Value;
char Buffer[16];
Value = 1;
for (i=0;i<=6;i++) {
XSLPformatvalue(Value,Buffer);
printf("\n16^%d = %s",i,Buffer);
Value = Value * 16;
}
Value = 1/16;
for (i=1;i<=6;i++) {
XSLPformatvalue(Value,Buffer);
printf("\n16^-%d = %s",i,Buffer);
Value = Value / 16;
}
The results are as follows:
16^0 = 1
16^1 = 16
16^2 = 256
16^3 = 4096
16^4 = 65536
16^5 = 1,049e+006
16^6 = 1,678e+007
16^-1 = 0,062
16^-2 = 0,004
16^-3 = 0
16^-4 = 1,526e-005
16^-5 = 9,537e-007
16^-6 = 5,96e-008
Further information
Trailing zeroes are removed. The decimal point is removed for integers. Numbers with absolute value less than 1e-04 or greater than 1e+06 are printed in scientific format.
