1. Suggestion for Eu 2.5
- Posted by Kurt Faasse <darkside at frontiernet.net> Jan 13, 2004
- 412 views
More options for printf would be useful. Large numbers could be separated by commas at the appropriate places by putting a comma after the percent sign, e.g. "%,d" to print 12345678 as 12,345,678. Right now I'm working on an astronomical program that involves huge distances, and comma separated numbers would be easier on the eye. I will have to write a routine that prints the numbers with commas as a separate function. If printf had this built in, the speed price would be negligible.
2. Re: Suggestion for Eu 2.5
- Posted by "Euman" <euman at bellsouth.net> Jan 13, 2004
- 432 views
Hi, Here are some routines (not written by me), they come in handy though. The Authors names have been retained. -- Thanks Don Phillips, Adds appropriate commas to large numbers ------------ function AddCommas( atom above ) atom below sequence answer integer sign atom after below = 0 sign = (above >= 0) * 2 - 1 above *= sign after = above - floor(above) above = floor(above) answer = {} if after != 0 then answer = sprint(after) answer = answer[2..length(answer)] end if while above != 0 do below = remainder( above, 1000 ) above = floor( above / 1000 ) if above then answer = sprintf(",%03d",{below}) & answer end if end while answer = sprint(below) & answer if sign = -1 then answer = '-' & answer end if return( answer ) end function -- Thanks Pete Lomax, strip comma's string -------------------------------- function RemCommas(integer id) integer k, lt text=getText(id) lt=length(text) while 1 do k=find(',',text) if k=0 then exit end if if k>lt then exit end if text[k..lt-1]=text[k+1..lt] lt-=1 end while return text[1..lt] end function Euman ----- Original Message ----- From: "Kurt Faasse" <darkside at frontiernet.net> > More options for printf would be useful. Large numbers could be > separated by commas at the appropriate places by putting a comma after > the percent sign, e.g. "%,d" to print 12345678 as 12,345,678. Right now > I'm working on an astronomical program that involves huge distances, and > comma separated numbers would be easier on the eye. I will have to > write a routine that prints the numbers with commas as a separate > function. If printf had this built in, the speed price would be > negligible.
3. Re: Suggestion for Eu 2.5
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jan 14, 2004
- 410 views
On Tue, 13 Jan 2004 06:12:38 +0000, Kurt Faasse <darkside at frontiernet.net> wrote: >More options for printf would be useful. Large numbers could be >separated by commas at the appropriate places by putting a comma after >the percent sign, e.g. "%,d" to print 12345678 as 12,345,678. Right now >I'm working on an astronomical program that involves huge distances, and >comma separated numbers would be easier on the eye. I will have to >write a routine that prints the numbers with commas as a separate >function. If printf had this built in, the speed price would be >negligible. You may want to test my financial formatting routine (probably without specifying a currency symbol). It is designed specifically that a column of large digits align on the decimal point, and also allows K or M indicators if the number is too large to fit in the specified width. I does not handle exponents at all, though. Let me know if there is some reasonable enhancement you think I could make. Regards, Pete http://palacebuilders.pwp.blueyonder.co.uk/euphoria.html