Float.htm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>Float#( value )</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. value = a number, or a string which represents a number
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. This is the same as Blitz's automatic type conversion. <br />
  21. So the two commands... <br />
  22. <br />
  23. y# = value <br />
  24. y# = Float( value ) <br />
  25. <br />
  26. ... do exactly the same thing. <br />
  27. <br />
  28. If Float is applied to a string it converts as much as possible: <br />
  29. <br />
  30. Float( "10" ) ...... result is 10.0 <br />
  31. Float( "3junk" ) .. result is 3.0 <br />
  32. Float( "junk3" ) .. result is 0.0 <br />
  33. <br />
  34. In the latter two examples Float() stops converting when it sees "j". <br />
  35. <br />
  36. The typical use is to force floating point arithmetic: <br />
  37. <br />
  38. y# = 12 / 5 .............. result is 2.0 because 12 / 5 = 2 ( integer division ) <br />
  39. y# = float( 12 ) / 5 .... result is 2.4
  40. </td>
  41. </tr>
  42. </table>
  43. <h1><a href=../2d_examples/Float.bb>Example</a></h1>
  44. <table>
  45. <tr>
  46. <td>
  47. ; Float example <br />
  48. ; ============= <br />
  49. <br />
  50. Print "Enter some text to be converted using Float()." <br />
  51. Print "Hit ENTER to exit." <br />
  52. <br />
  53. Repeat <br />
  54. s$ = Input$(">") <br />
  55. If s$<>"" Then <br />
  56. Print "Float("+Chr$(34)+s$+Chr$(34)+")=" + Float(s$) <br />
  57. End If <br />
  58. Until s$="" <br />
  59. <br />
  60. End
  61. </td>
  62. </tr>
  63. </table>
  64. <br>
  65. <a target=_top href=../index.htm>Index</a><br>
  66. <br>
  67. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Float&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  68. </html>