Re: Can printf() be made smarter?

new topic     » goto parent     » topic index » view thread      » older message » newer message
MarkB said...

Hey all, I'm a long time lurker and hobby programmer but new to posting.

I'm working on a program to read a text file, process the file and write results in a text file for another program to read. The input file, an AutoCad .dxf, contains a lot of integers and floats in text format with varying decimal places depending on the drawing details. Ideally my program would write some of these numbers in the output file with the same precision that they are read, i.e. with the same number of decimal places.

...

Hi Mark,

1) If the input formats are the same as the output formats you could simply pass the values directly as text and not worry about text to atom to text conversions.

2) However, if you do need to process the values at all numerically and can't escape printf(), I suggest writing your own routines to take care of the different styles (if there aren't that many). You don't have to stick to the printf() conventions either:

sequence t = myprintf("This value is %10f2", A) --> This value is 0000000123.45 
sequence t = float10_2(A) --> 0000000123.45 
sequence t = myfloat(A, 10, 2) --> 0000000123.45 

Spock

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu