• Post Reply Bookmark Topic Watch Topic
  • New Topic

array of random numbers  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have managed to get an array to generate random numbers between 0 and 99. However, I would also like the array to contain negative numbers as well but cannot work out how to do this?

Anyone able to offer advise on this please?

My code is:

 
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
get the number and perform minus operation with 0 for example:

0-10 => -10

hope that is what you are looking.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max Random = 200

your number = -100 + generatedRandomNumber

J.
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!