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:
- "sticking together" 2 outputs of
next
not give random value in target range. math not work strings. - 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
Post a Comment