Print "Single"

Discuss the Firewing language

Print "Single"

Postby demanik » Sat Jan 04, 2014 3:57 pm

How to transfer Single format (floating point) number to String for a print to the display
Image
User avatar
demanik
 
Posts: 56
Joined: Sat Aug 17, 2013 5:53 pm
Location: Ukraine

Re: Print "Single"

Postby David John Barker » Sat Jan 04, 2014 5:20 pm

User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Print "Single"

Postby demanik » Sat Jan 04, 2014 5:30 pm

Thanks.
And whether there is an opportunity to set number of figures after a point
Image
User avatar
demanik
 
Posts: 56
Joined: Sat Aug 17, 2013 5:53 pm
Location: Ukraine

Re: Print "Single"

Postby David John Barker » Sat Jan 04, 2014 6:01 pm

No. CStr() will not do that. You will need to roll your own solution.
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Print "Single"

Postby David John Barker » Fri Jan 17, 2014 9:57 am

I've added some new routines to the "Convert.bas" module which will now allow you to convert floating point numbers to strings. The new routines can control the number of digits after the decimal point and also the pad count and pad character before the whole part. For example:

Code: Select all
sub main()
  dim val as double
  val = 0.0123456789012345
  console.write(Str(val,16),13,10)      ' output 0.0123456789012345
  console.write(Str(val,3),13,10)       ' output 0.012
 
  val = 123.621689
  console.write(Str(val,3,5),13,10)     ' output 00123.621
  console.write(Str(val,6,5,"*"),13,10) ' output **123.621689
end sub


You can download the new BETA from here:

http://www.firewing.info/pmwiki.php?n=Firewing.Download

The routines are reasonably accurate and should meet most users needs. Should you wish to improve on the conversion routines, just click on the "Convert" module in the explorer window to view the source code (the routines are at the end of the module).
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Print "Single"

Postby demanik » Fri Jan 17, 2014 10:34 am

thanks, I will try
Image
User avatar
demanik
 
Posts: 56
Joined: Sat Aug 17, 2013 5:53 pm
Location: Ukraine


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest

x