[futurebasic] Re: [FB] Double-precision vars (#)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1999 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Sat, 12 Jun 99 00:49:14 -0500
>I'm working on a program in which I store a series of double-precision 
>variables in a chunk of memory I access through a handle (arrays will not do 
>in this situation). I'm having a bit of trouble moving correctly this data 
>with BLOCKMOVE, because I think I'm not moving the correct number of 
>bytes. I 
>read that the default number of bytes for double-precision variables was 8 
>(for 12 digits of accuracy). Since I have not changed my preferences dialog 
>in FBII, and checked to make sure they were the defaults anyways, I 
>assumed 8 
>bytes was how many I should be BLOCKMOVing for each variable. But I'm still 
>having trouble. Does anyone know why I might be having trouble? The values I 
>get when I try to retrieve the data from this string of double-precision 
>variables in memory are funky....
>
>Here's the main line of what I use, where varID is the number of the 
>variable 
>I want to retrieve the eight bytes for and thus get its value (1 being the 
>first variable in memory):
>
>BLOCKMOVE [gNumVData&]+((varID-1)*8),@dummy#,8
>
>Any suggestions, tips, comments? I'm having trouble squishing this 
>particular 
>bug. Is there some stupid mistake I'm making and just not catching it?

Hi Matt,

Suggestion #1: (a possible improvement)
Why not use this format:
  dummy#;8 = [gNumVData&]+(varID-1)*8
It is actually a bit more efficient.

Suggestion #2: 
Do you know for sure that the data in your handle is correct? If it is, 
your blockmove looks like it should work. How do you get the data into 
the handle? How do you see the value of dummy#? Is your handle valid? Is 
varID>0?

Suggestion #3: (Best solution, IMO)
Use XREF@ to view (and use) your data:
  DIM   gNumVData&
  XREF@ gNumVData#(99)  'do this where you dim your globals

  dummy# = gNumVData#(varID-1)  'do this where you use the data
  gNumVData#(varID-1) = dummy#  'It works the other way, too!

This way, you might not even need the dummy# var, you can use the handle 
data directly just as you would an array element, but it never leaves the 
handle, and will accomodate any size handle you can fit in memory.

Tip:
Don't be confused (as I was) by the table on p. 361 of the Reference 
Manual, where it shows # as single precision and ! as double precision. I 
checked it out--the way you have it is correct!

If these don't help, please send more details.
 0"0
 =J= a  y
  "