Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven.umd.edu!umbc3.umbc.edu!math16.math.umbc.edu!rouben From: rouben@math16.math.umbc.edu (Rouben Rostamian) Newsgroups: comp.unix.questions Subject: How to separate numbers in three-digit groups in C Message-ID: <1991Jun23.174550.14820@umbc3.umbc.edu> Date: 23 Jun 91 17:45:50 GMT Sender: newspost@umbc3.umbc.edu (News posting account) Organization: University of Maryland Baltimore County, Mathematics Department Lines: 20 Originator: rouben@math16.math.umbc.edu I need help with printing numbers (floating or integer) in C. I would like to display the numbers in three-digit comma-separated format. For instance, the integer 12345678 should be printed as 12,345,678. The floating point number 1234.56789 may be printed as 1,234.5678 or as 1,234.567,8. I wish the printf function had an option for such formatting, but as far as I know, it doesn't. I guess the ideal solution would be to extend the format options for the printf command. Perhaps a Printf function may be defined which accepts the standard formatting strings of the printf function, but which also accepts additional conversion characters to print comma-separated digits. I do not wish to re-invent the wheel if someone has already done this. So please let me know if there is something similar available somewhere. -- Rouben Rostamian Telephone: (301) 455-2458 Department of Mathematics and Statistics e-mail: University of Maryland Baltimore County bitnet: rostamian@umbc.bitnet Baltimore, MD 21228, U.S.A. internet: rouben@math9.math.umbc.edu