•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileThe $F% option must be entered as the first line of a function to have an
effect. It instructs the compiler to output the return value of the function
as an integer. The default output is a floating point value.

This default behavior is probably some throw back to the classic days of BASIC
where everything was floating point. Unless you care about it yourself at each
and every function, you will always get the slower floating point.

$F% does not specifically imply long% type only. The compiler actually checks
the variable at 'RETURN x' and adjusts the code automatically based on the
variable type. In other words the compiler will auto cast it to the correct
integer type. String functions are handled automatically and $F% is ignored.

To be more precise, the '%' (percent sign) means return any integer type, it
does not mean return only long type. The compiler does not report syntax
errors within compiler commands, it simply ignores them.

Not only does this speed up your functions but it reduces the code size of
each function. Option $F% eliminates two library calls, BSR FITOF (integer to
float) and BSR FFTOI (float to integer). Both of these add several lines of
needless assembler overhead to each function call made!  Quite literally if
$F% is missing the function converts the output to floating point and then the
assignment to some variable converts it back. The effect of this at each call
of a function is, integer -> float -> integer, which is for sure not very
optimal.

Memo: The compiler requires this command to be on the very 1st line of the
      function or it has no effect at all. Example:

      a%=@test             !BSR FFTOI (flt to int)
      PRINT a%
      EDIT
      FUNCTION test
        $F%                !absolutely has to be the very 1st line!
        RETURN 1.23456789  !BSR FITOF (int to flt)
      ENDFUNC

      A space between '$' and 'F%' will cause it to fail. Example:
      $ F%  !compiler fails to see the option

      According to some French manuals $F| and $F& are valid options.
      These do not work, in fact it will result in a float being returned!
      I've also seen $F$ and $F! in other peoples source listings and they
      do not work.

      To be precise, no where in the compiler source code is a check for
      $F!, $F!, $F&, or $F$. All of these produce slower floating point
      output. The compiler has exactly one check for '$F%' only. Any books
      or manuals that state otherwise are incorrect.

      DEFFN functions always return floating point values.
      They must be recoded into multi-line functions to speed them up.