C# Join 2 Numbers (INT) into 1 longer INT -


it might quite funny didn't know how search find answer one.

i use when want join strings "string = "something" + "somethingelse" "

but how int? :)

random r = new random(); int lvfirst = r.next(485924948); int lvsecond = r.next(39); int lvdone = lvfirst + lvsecond; globals.globalint = lvdone; 

i tried doing 1 long int doesn't seem work says long if can me how join 2 random numbers 1? need 1 random number max "48592494839"

thanks lot!

there 2 problems code:

  1. "sticking together" 2 outputs of next not give random value in target range. math not work strings.
  2. instead of returning result stores in global variable.

if want value in range specify, use

var result = (long) (r.nextdouble() * 48592494839); 

this still not work any target range, comfortably meet specific requirements.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -