Search found 147 matches

by stevepoole
Tue Dec 12, 2017 12:04 am
Forum: Software & Programming
Topic: Difference between inline and full version of BASIC constructs
Replies: 7
Views: 227

Re: Difference between inline and full version of BASIC constructs

Hi George, It is possible to interweave many different SELect and/ or IF statements in both long and inline codes. Inline code can be useful when you want to keep a lot of code on one page without needing lots of scrolling. But it can be horrible to debug later... As always, the key to good coding i...
by stevepoole
Thu Dec 07, 2017 6:16 am
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi Martin, Yes, I can confirm what Per has posted. The programs have been beta-tested and are bug-free now. Tested Ok over the full floating-point range of -,+ 9E -,+ 615 And, they Turbo_Compile OK on my system, a QPC2 laptop. Many thanks to Per for converting his _rext code into Basic for us all......
by stevepoole
Sat Dec 02, 2017 7:32 am
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi again, For correct powers of two, change the second loop : for x=$81F to 0 step -1 if s=-1: if m<=ovf: m=m+m: else exit x if s=+1: if m< ovf: m=m+m: else exit x end for x Tested for -1e-615, -1e615, -pi, pi, 1e615, 1e-615 That is a huge range to check in very small STEPs. But seems OK for the mom...
by stevepoole
Sat Dec 02, 2017 5:27 am
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi Per,

After still more testing, I note that the series -1, -2, -4, -8, -16 etc gives false results.

I have tweaked a bit, but still cannot locate the cause of the bug.

Perhaps you can ?

Regards,
Steve.
by stevepoole
Thu Nov 30, 2017 3:57 pm
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi Per,

Just been testing your latest version which seems to be dead accurate....

The first loop can also be written as :
for x = $81F to $FFF : if m < ov2 : exit x : else m = m / 2
This allows two lines to be deleted, but is it faster ?

Thanks for your code !
Best wishes,
Steve.
by stevepoole
Thu Nov 30, 2017 11:29 am
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi again, Per's solution needs several tweaks to get all the right answers , (Tested against the TURBo codes I gave). Line 10 ovf=2^30 is now OK, but : read 190 If m> (2^31) THEN delete 270 and 300 read 280 if m>=ovf: exit x: else m=m+m This now works in the full range of -1E-615 to 1E615 ! If you f...
by stevepoole
Thu Nov 30, 2017 9:39 am
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi Per, Thanks for your latest code, which I just tested : Line 10 should read ovf = 2^31 to get a correct answer, (compared to the TURBO example for PI). But then the routine fails for floats larger than 1E9 ... The function should operate from -1E-616 to 1e615. I will try to see if I can debug it....
by stevepoole
Wed Nov 29, 2017 6:11 pm
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi again,

Using Turbo :

100 f$ = FLOAT$(PI) : s$=''
120 for i=1 to 6 : s$=s$ & ( HEX$( CODE( f$(i),8))
130 PRINT s$

Will convert 3.141592654 into 08026487ED51, the HEX value.

Regards,
Steve.
by stevepoole
Wed Nov 29, 2017 4:21 pm
Forum: Software & Programming
Topic: Floating point conversion
Replies: 17
Views: 841

Re: Floating point conversion

Hi,

Turbo has a FLOAT$ function, ' which returns a six-character string of the specified floating-point number '. See Turbo manual : page 190.

Eg : F$= FLOAT$(PI) : returns 6 ASCII characters ( whose codes are : 8 , 2 , 100 , 135 , 237 , 81 )

Regards,
Steve.
by stevepoole
Tue Nov 28, 2017 10:32 pm
Forum: Software & Programming
Topic: BASIC: Returning non-scalar values from Procs
Replies: 12
Views: 603

Re: BASIC: Returning non-scalar values from Procs

Hi, The nearest thing to 'C' style 'pointers' on the QL is possibly to reserve memory and PEEK and POKE values into it. That way you get beyond the QL array integer limit of dimensions, and have the advantage that the memory is globally accessible if you wish. If you are good enough to use 'pointers...

Go to advanced search