It was I who required a way to do this. Thanks for this. Very well timed
since I now need to print unsigned 32 bit integers and unfortunately
none of the DEC$ functions can do this. Hopefully a few changes to this
will provide a solution.
On 05/03/2012 09:59, Michael Bulford wrote:
Some weeks ago
someone enquired as to how to print numbers in non exponent form. I believe it
was George Gwilt who suggested
using CDEC$. Here is a function that I
use ...
750 DEFine
FuNction comma$(num)
760 LOCal t, fra
770 IF num< 0 : RETurn "-"
& comma$(ABS(num))
780 IF num< 1000 : RETurn num
790 IF num/1000> 2^31-2 : RETurn num
: REMark otherwise INT(num/1000) will fail
800 t = INT(num/1000)
810 fra = num – t * 1000 : IF
"e-" INSTR fra : fra = 0
820 RETurn comma$((t))&
","& FILL$("0",(fra<100)+(fra<10)+(fra<1 AND
fra>0))& fra
830 END DEFine comma$
This only works
properly for whole numbers, and if the number cannot be converted then the
exponent form is returned.
PRINT
comma$(2^31) gives 2,147,483,648
PRINT
comma$(1000.753) gives 1,000.7529998
Michael Bulford
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm