Help Contents / Arithmetic / Print formatting / Form

Form num width precision
(Form aword width)

the first form  outputs a word containing a printable representation of "num", possibly preceded by spaces (and therefore not a number for purposes of performing arithmetic operations), with at least "width" characters, including exactly "precision" digits after the decimal point. (If "precision" is 0 then there will be no decimal point in the output.) 

As a debugging feature, (FORM num -1 format) will print the floating point "num" according to the C printf "format", to allow 

	to hex :num 
		op form :num -1 "|%08X %08X| 
	end 

to allow finding out the exact result of floating point operations. The precise format needed may be machine-dependent. 

The second form outputs a new word  containing the truncated aword  with as many spaces appended to it  to make it have width number of characters. 

Examples: 

	Form pi 16 14		;3.14159265358979  ;-) 
	Form exp 1 10 8		;2.71828183  ;-) 
	(print (Form [Hallo World!] 20) [...and some more])	 
	;Hallo World!         ...and some more 


next: intForm
