#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# RandomRange help

Member Posts: 31
[b][red]This message was edited by ajtr211 at 2002-12-14 8:44:31[/red][/b][hr]
[b][red]This message was edited by ajtr211 at 2002-12-14 8:42:29[/red][/b][hr]

I
50 Random integers between the range of
-20 and +20

• Member Posts: 348
well,the first thing is to write a random-number generator.there are many possible ways to do this,but my prefered way is to read a value from the timer (port 40h) and to alter it with an other value from a variable.example in pseudocode (no,i wont do your homework ):

a = port[40h]
randnumber = ((randseed xor a) - a) rol 5

now you could use a modulo-division to get a value between 0 and 20:

randseed = randseed mod 21

then you have to convert the binary number you should have in memory or a x86-register to a ASCII string.you could do this in a loop by divide your number by 0ah.the modulo of this is your digit,simply add 30h and you have the ascii-code.write this numbers to a string and output it.

• USAMember Posts: 4,496 ✭✭

____ / http://forcoder.org / free ebooks and video tutorials about \ Scratch C++ Ruby C C# Visual Basic PHP Perl Swift Assembly JavaScript Objective-C Java R Python MATLAB Visual Basic .NET PL/SQL Delphi Go Lisp Scala Rust Dart Hack Alice Bash Awk Transact-SQL FoxPro Clojure LabVIEW Crystal Kotlin D ML VBScript Prolog Julia Scheme Erlang Logo Fortran F# Ada SAS COBOL ABAP Apex Lua \ __