Mega Code Archive

 
Categories / Ruby / Development
 

Sprintf Flags and Field Types

Flag    For field types         Description [space] bdeEfgGiouxX            Places a space at the start of a positive number. [1-9]$  All field types         Absolute number of an argument for this field. #       beEfgGoxX               For the field b, prefixes the result with 0b; for o, with 0; for x, with 0x; for X, with 0X. For e, E, f, g, and G, adds decimal point. For g and G, does not remove trailing spaces. +       bdeEfgGiouxX            Adds a leading plus sign (+) to positive numbers. -       All field types         Left-justifies the result. 0       bdeEfgGiouxX            Pads the result with zeros (0) instead of spaces. *       All field types         Uses the next argument as the field width. If negative, left-justifies the result. If asterisk (*) is followed by a number and a dollar sign ($), uses argument as width.