FB II Compiler
I'm writing a program that requires large amounts of calculus (fourier transforms on long dataset : 2048 or 4096 real or complex numbers); works but very time consumming. So i'm looking to translate the inner loops such as to use the SANE routines. It is not an easy task and some fears arose for me when i see 2 about the 3 examples provided with FBII (namely Formula Translation.bas and DEF SANE.bas) that does not run on my machine. The first one refuses to fill an extended variable with the value of a single var.
dVar = #1.004 '<this one is ok
bVar = #b! '<refused before compilation (expected other thing than b!)
Anyway, if I have not completely misunderstood all I have read on the subject, I have serious doubts on the equivalence between the BCD formula and the proposed code fragment using SANE .
The second example compiles well but brings me to Macsbug when doing the sine serie .
Has somebody here similar or different experience. Is it my mac (quadra 950, sys 7.5.3) or a known bug or a bad copy?
There appear to be 2 methods of accessing SANE from FB.
Method A uses SANE Calls.incl.
The calls themselves work, and are demonstrated in SANE Tester.main. (Unfortunately this example is strangely written, with no output window; however it can be seen to work if you insert WINDOW 1 on the line before the CLS statement).
The outline for this method is:-
1 Set up double precision BCD variables in FB
2 Convert the values to extended (such as myExtVar.10)
3 Perform SANE calculations
4 Convert back to FB
The conversions can be done using two functions in SANE<->BCD.incl.
' BCD# = FN X2BCD#(Extended Var)
The FNs assume that your double precision BCD variables are 12 bytes, which is not necessarily true, depending on FB Preference settings. I recollect finding and repairing another bug in one of these conversion routines, but I don't have the details right here. Yet another problem is that the conversion is _very_ slow, so that you risk losing the time that you saved with fast SANE calculations.
' FN BCD2X(Numbertoconvert#,Extended Var)
You cannot convert from FB BCD to extended by writing bVar=#b!. The Formula translation.bas example is nonsense.
If you can fight your way through all this, there may be major speed and accuracy gains from SANE.
Method B uses a set of built-in FB DEF statements, such as:-
DEF FX2L(value, myLongInt&)I found these so poorly documented that I could not use them.
DEF SANE (myLongInt&, myVal, _foSinX, _ffLng )
DEF ELEMENTARYSANE (myVal, _foNeg, _ffExt )
Executive summary: although I did manage to get some substantial floating point work done with Method A, it was a gruelling experience, and I am now waiting for FBIII.