Author |
Topic: Determining the FLOAT mode in use. (Read 504 times) |
|
rtr2
Guest
|
 |
Re: Determining the FLOAT mode in use.
« Reply #1 on: Mar 24th, 2015, 5:05pm » |
|
on Mar 24th, 2015, 3:39pm, sveinioslo wrote:| There is perhaps a better and safer way ? |
|
Your code seems to report the *FLOAT mode incorrectly in v6.00a. Here I get:
Code:floatmode is 80
floatmode is 80
floatmode is 80
BBCv_6 If you want to find the true *FLOAT mode you can do so directly by testing the relevant flag bits at ?419, which is documented on the Wiki:
Code: CASE ?419 AND 3 OF
WHEN 0: PRINT "*FLOAT 40"
WHEN 1: PRINT "*FLOAT 64"
WHEN 2: PRINT "*FLOAT 80"
ENDCASE But if what you want to know is the precision of a (suffixless) 'variant' numeric variable the most direct method is to use CALL:
Code: DEF FNprecision
LOCAL M%,P%
DIM P% LOCAL 10
[OPT 0
.M%
movzx eax,byte [ebp+6]
mov edi,[ebp+2]
mov [edi],eax
ret
]
CALL M%, P%, a
= P% * 8 That also tells you the version, because if the returned value is 40 or 64 it must be BB4W v5 and if the returned value is 80 it must be BB4W v6.
Richard.
|
| « Last Edit: Mar 24th, 2015, 5:06pm by rtr2 » |
Logged
|
|
|
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Determining the FLOAT mode in use.
« Reply #2 on: Mar 24th, 2015, 7:21pm » |
|
Great, thank you!
The precision of a (suffixless) 'variant' numeric variable was exactly what i wanted. I do not know, if knowing the version will be required, but just i case...... Forgot about the 'Interpreter internal variables' page, just found some other needed info. 
Svein
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Determining the FLOAT mode in use.
« Reply #3 on: Mar 25th, 2015, 06:47am » |
|
on Mar 24th, 2015, 5:05pm, g4bau wrote:| But if what you want to know is the precision of a (suffixless) 'variant' numeric variable |
|
Here's an even more straightforward method, which works by finding out how much memory the variable occupies:
Code: DEF FNprecision
LOCAL s{}
DIM s{a}
= DIM(s{}) * 8 Richard.
|
|
Logged
|
|
|
|
sveinioslo
Developer
member is offline


Posts: 64
|
 |
Re: Determining the FLOAT mode in use.
« Reply #4 on: Mar 25th, 2015, 3:47pm » |
|
Nice 
Svein
|
|
Logged
|
|
|
|
|