Welcome! Log In Create A New Profile

Advanced

format$

Posted by fclaro 
format$
October 30, 2013 03:52PM
Hi Jim
About format$
in Documentation/Keywords/format$, I taking some examples
I have problems to format decimal places:

some examples in documentation do not work as expected

"
| ByPic Version 2.08
| Saves 0 |
| BV523 Serial# 201310020
| |
| Documentation www.bypic.co.uk |
| |
| Copyright Jim Spence 2013 |
======================================
0:/ ok dim f#

0:/ ok f#=123.779

0:/ ok print format$("number %f.2 ",f#)
ERROR (0) <f.> undefined function or variable at print

0:/ ok print format$(" number %f2 ",f#)
number 123.7790002
0:/ ok print format$(" number %d2 ",f#)
number 1232
0:/ ok print format$("n %f ",f#)
n 123.779000
0:/ ok print format$("n %g ",f#)
n [f5].67295e-319
0:/ ok print format$("n %d2.2 ",f#)
n 1232.2
0:/ ok
"
Please help me to use formatation for 2 decimal places

Fernando Claro
Re: format$
May 17, 2016 07:58PM
Hi ,

Not sure if this is still working correctly , I am also trying to just split a float to 2 decimal places using the following...

 dim f#
f# = 123.779000
print format$("%f.2",f#)

the code above results in : 123.779000.2

is this a bug? or how do i obtain 2 decimal places ?

Many Thanks
Luke
Re: format$
May 18, 2016 09:45AM
look up 'C printf' it follows the same rules except only one variable is allowed. I think it should be "%.2f"
Re: format$
May 25, 2016 06:05PM
Thanks , All sorted "%.2f" worked
Sorry, you do not have permission to post/reply in this forum.