
With PB 5.00 works well.

Code: Select all
Define .d
Macro RND(v1,v2,ndecimales=3)
(Random(1E#ndecimales#)*(v2#-v1#)/1E#ndecimales#+v1#)
EndMacro
v=RND(1E-18,1.0,12)
Code: Select all
Define .d
Macro RND(v1,v2,ndecimales=3)
(Random(1E#ndecimales#)*(v2#-v1#)/1E#ndecimales#+v1#)
EndMacro
v=RND(1E-18,1.0,12)
Code: Select all
Debug Random(1E12)
Code: Select all
v=(Random(1E12)*(1.0-1E-18)/1E12+1E-18)
What happens if run for example Random($100000000) in a 64 bit PB?Syntax
Result = Random(Maximum)
Description
Returns a random number between 0 and the given maximum value.
Parameters
Maximum The maximum value. It may not exceed the maximum positive integer value.
1E12 is a double larger than an integer on x86, random() is expecting an integer.Psychophanta wrote:With PB 5.21 it returns an error of negative value for Random() PB function, but the value is never negative.
And if you pass a negative quad value nothing bad happens.luis wrote: If you pass an integer up to max positive integer value as specified in the doc nothing bad happens.
Still the same reason.Psychophanta wrote: And if you pass a negative quad value nothing bad happens.
Code: Select all
d.d = 1e12
i.i = d
Debug i ; -2147483648 -> DOH ! IT'S NEGATIVE BECAUSE I'M PASSING THE WRONG STUFF !
Code: Select all
q.q = -9223372036854775000
i.i = q
Debug "q = " + RSet(Bin(q),64,"0")
Debug "i = " + RSet(Bin(i),64,"0")
Debug i ; 808 -> DOH ! IT'S POSITIVE, ONLY WRONG BECAUSE I'M PASSING THE WRONG STUFF !
Code: Select all
Debug Random(-9223372036854775000) ; just seems to work (sorta) and to not complain, in reality this is Debug Random(808) so it has no reason to complain.
You are calling what you don't understand lies.Psychophanta wrote: So, PLEASE, be rigorous, and don't try to convince everybody about those lies.
Oh, you sad excuse for a wanna-be programmer... try to follow this time.Psychophanta wrote:Sorry man, but in my first example i pass 1E-18, which is NOT a negative number, in opposition to you say and the compiler says.
Code: Select all
v=RND(1E-18,1.0,12)
Code: Select all
v=(Random(1E12)*(1.0-1E-18)/1E12+1E-18)
I've explained it to you with a simple example, if you don't understand it it's fine. It happens.Psychophanta wrote: 1E12 IS NOT a negative value either.
Wrong (i.e. lie)!Psychophanta wrote:...in my first example i pass 1E-18...
Code: Select all
Define .d
Macro RND(v1,v2,ndecimales=3)
(Random(1E#ndecimales#)*(v2#-v1#)/1E#ndecimales#+v1#)
EndMacro
v=RND(1E-18,1.0,11)
Debug v
;NOTICE: (Pow(2,31)-1 = 2147483647.0), which is higher than (1E11 = 100000000000.0). But NO error reported by compiler.
;but:
; v=RND(1E-18,1.0,12)
; Debug v
;NOTICE: (Pow(2,31)-1 = 2147483647.0), which is higher than (1E12 = 1000000000000.0). But ERROR reported by compiler.