Hello im trying to use random integer range and the values that i get is out ouf the ones that i set.
for example:
sw $a0, 0($s0)
li $a0, 1000
li $a1, 3500
li $v0, 42 #random
So i just want it to be random numbers between 1000-3500 but it gives me any random number.
Can you please help me to understand where my mistake is.
$a0
is the random seed, not the lower bound. You should set $a1
to 2501
to generate 0-2500 random number, and add 1000 to the result.
sw $a0, 0($s0)
li $a1, 2501
li $v0, 42 #random
add $a0, $a0, 1000
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.