January 16, 2021, 05:48:50 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] RND substitute by jfk EO-11110 [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] RND substitute by jfk EO-11110 [ 1+ years ago ] (Read 747 times)
BlitzBot
Jr. Member
Posts: 1
[bb] RND substitute by jfk EO-11110 [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:43 AM »
Title :
RND substitute
Author :
jfk EO-11110
Posted :
1+ years ago
Description :
This is pretty useless, however if you will ever need a function that does RND without to use Blitz's built in Rnd() function then this may be useful.
Note: the sequences are NOT reproducable, so whenever you run it the numbers will differ.
No smart maths here, just a simple overflow usage.
Code :
Code: BlitzBasic
Graphics
640
,
480
,
32
,
2
SetBuffer
FrontBuffer
(
)
Global
rnd_inc
Repeat
Plot
my_RND#
(
100
,
540
)
, my_RND#
(
100
,
380
)
Until
KeyDown
(
1
)
End
Function
my_RND#
(
v1#,v2#
)
rnd_inc=
(
rnd_inc
)
+
(
ScanLine
(
)
*
MilliSecs
(
)
)
Mod
3500000000
rnd_st$=
Abs
(
rnd_inc
)
rnd_st$=
Right
$
(
"000000"
+
Abs
(
rnd_inc
)
,
6
)
rnd_st$=
"0."
+rnd_st$
n#=v1+
(
Float
(
rnd_st$
)
*
(
v2-v1
)
)
Return
n
End Function
Comments :
_33(Posted 1+ years ago)
Do you know how SLOW it is to convert a numeric to a string, then use Right$, concatenate the string with something else, convert it back to numeric....
?
Azathoth(Posted 1+ years ago)
You're overwriting 'rnd_st$' :rnd_st$=Abs(rnd_inc)rnd_st$=Right$("000000"+Abs(rnd_inc),6)
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] RND substitute by jfk EO-11110 [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal