× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



But it doesn't preserve the lead 0 if the value is less than 1.00

This, .95, is an invalid JSON number
0.95 is a valid one.


In a recent reply, I suggested the use of the C Standard Library sprintf
function.
For example, you could do this:

DCL-PROC print_decimal EXTPROC('sprintf');
DCL-PI print_decimal INT(10); // may not return a value at all.
parm_dstBuffer POINTER VALUE;
parm_format POINTER VALUE OPTIONS(*STRING);
parm_theDecimal FLOAT(8) VALUE;
END-PI;

DCL-S myBuffer CHAR(20) INZ;
DCL-S myFigure PACKED(9:2) INZ(-.95);
DCL-S byteCount INT(10) INZ;

byteCount = print_decimal(%ADDR(myBuffer): '%.2f': myFigure);

// myBuffer will have '-0.95' just as you want.

END-PROC;

Note the obvious conversions the compiler will do for you with the float
type in sprintf. I always use sprintf when I find myself with imprecisions
like this.

Hope this helps.

Javier Sanchez.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.