Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

22
  • 1
    yes, A=4/2 and A=3/2 will always produce a float no matter what. even if the result is integral in the end. I banged my head on the wall when I wrote an Oric basic to C converter because in C 3/2 yields 1... Good luck finding the bugs in the converted games... Commented Mar 16, 2020 at 22:44
  • 1
    The Integer variables in MS BASIC, at least on the 6502 variant, have only two real application: 1.) in some (fairly rare) situations assigning a result to an integer variable might save you one call to INT(X) when you need to throw away a fractional part, and 2.) and much more importantly, while simple integer variables take as much RAM as floats, integer arrays can be a big space saver - they take only 2+2*n bytes for n elements, not 2+5*n as float arrays do. Of course this has to be balanced against the slower processing and the additonal "percent" characters in your code. Commented Mar 17, 2020 at 12:35
  • 1
    "Interesting here is that the use of constants does not result any relevant speed up" - luck basically, you're using a one-byte ASCII const, as opposed to a one-byte var name. The rest of the conversion is the same. I'm curious what happens if you change 3 to 3000 etc. Commented Mar 17, 2020 at 15:02
  • 1
    For giggles, I wrote a 3-line program that set up 10 vars = 10 and then FOR I=1 TO 10000. On a C64 emu, that's 18.4 seconds. Adding a line 5 with I=0 reduces it to 14.4 seconds! Clearly the Atari approach is better and goes to show just how bad the FP code is. Commented Mar 17, 2020 at 15:06
  • 3
    To validate your test program, I modified it very slightly to run on a BBC Master: dropbox.com/s/yn0zzavdyiv8uxq/… This demonstrates that on a BASIC which does have native support for integers, they do have a performance benefit over floats. Commented Jun 27, 2020 at 21:14