WeBWorK Problems



by Adam Z -
Number of replies: 4

Hello all: 

I know that  random( 1,200,1) generates random numbers with the step of 1  ( integer )

random(1,100,0.1) generates random numbers with steps of 0.1. 

How to generate decimal numbers with only one decimal place or two ??

In reply to Adam Z

Re: Random

by Glenn Rice -

You already have it.  If you want a decimal number with one decimal place use random(1,100,0.1).  If you want two decimal places use random(1,100,0.01).

In reply to Glenn Rice

Re: Random

by Alex Jordan -

And if you really want exactly two decimal places and no possibility for fewer, you can combine like :

random(1,100,0.1)  +  random(0.01,0.09,0.01)

to guarantee something nonzero in the tenths place. Or depending on your preference:

random(10,1000)/10  +  random(1,9)/100

In reply to Alex Jordan

Re: Random

by Adam Z -
I like this, I am still learning. All of these are helpful. Thank you, Alex :)