Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random number guessing game.....
#21
thats nice, i wish the RND function could be used like this

Code:
num = RND(x1 to x2), Step x

i remember one program that u could use to program basuc that worked like this, it was nice, u could go like

Code:
num = RND(0 to 10), Step 2

and it would be a 0,2,4,6,8, or 10, iot worked great

now while were talking about math functions, is there anyway to round a number to no decimal places in qb?
Reply
#22
Quote:now while were talking about math functions, is there anyway to round a number to no decimal places in qb?

INT()
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply
#23
Code:
Declare FUNCTION int.rnd(base1 as long, base2 as long) as long

FUNCTION int.rnd(base1 as long, base2 as long) as long
    Return int((rnd*base2)+base1)
END FUNCTION

looking at this code posted i tested and it appears incorrect ie

int.rnd(0, 5) should return number in range 0, 1 , 2 ,3, 4, 5

but it will never return 5

This is waht i use requires #include "crt.bi"

Code:
Function GetRand(nmin As uInteger, nmax As uInteger)As uInteger
  GetRand = Int((nmax - nmin + 1) * (rand() / RAND_MAX) + nmin)
End Function

however you can use this also, this is the native fb version, not sure which is faster

Code:
Function GetRand2(nmin As uInteger, nmax As uInteger) As uInteger
  GetRand2 = Int((nmax - nmin + 1) * Rnd + nmin)
End Function


EDIT : sorry just saw im in a QB forum , here is QB one

Code:
Function GetRand2(nmin As Long, nmax As Long) As Long
  GetRand2 = Int((nmax - nmin + 1) * Rnd + nmin)
End Function
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#24
Quote:
axipher Wrote:now while were talking about math functions, is there anyway to round a number to no decimal places in qb?

INT()

i was playing around with a code i dled and figured out that i can use

Code:
PRINT USING "###"; number

it works fine for numbers from -999 to 999 which is wat i want, its for stats and exp in an rpg
Reply
#25
Quote:I suggest you read ALL of Vic's tutorials, which can be found on this site...

Whatever happened to Vic, anyway? I read his tutorials about 2 years ago. He taught me almost everything I know about programming in any form of BASIC.
quote="Bruce Raeman"]Anatomy (n): something everyone has, but which looks better on a girl[/quote]
Reply
#26
Isn't vic "v1ctor"? That would be the guy who made and is still updating FB...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#27
I really don't think so, Aga. Although we should really ask him. Vic Luce, AKA radiohands made tutorials that taught me loads. Although he disappeared by the time I got involved in the community.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)