Random integers

  • Thread starter Thread starter John T
  • Start date Start date
J

John T

I'm trying to create pairs of random integers that ALWAYS add up
correctly. Sometimes due to the rounding up process I get an error
of 1 when added together.

If you are kind enough to reply by email using "reply to" take out
"the rubbish" from my address.

Cheers
John T
 
On Thu, 18 Mar 2004 12:50:58 -0800,


Example: I want 19 + 13 to equal 32, not 31 or 33 !
Unfortunately working in the education tends to restrict creative
interpretations and stiffle surreal debate!
 
Hi john
this would add up correctly. Question: do you have these problem then
using mathematical calculations like divisision, etc. or can you post
an example of your data and the formula you used which results in a
wrong result
 
On Thu, 18 Mar 2004 22:52:13 +0100, "Frank Kabel"
Just addition & subtraction at the moment.

I'm preparing files for teachers to use on a data projector to rapid
recall of number bonds.
I've put two data cells (B3 & D3) onto a sheet called "setup" to allow
the teacher to set the range of random numbers generated.

On the "quiz" spreadsheet I've used
=RAND( ) *( setup!B3-1)+1 and =RAND( ) *( setup!D3-1)+1 to
generate 2 random numbers to be added.
I have a cell that adds the two numbers together, along with a macro
which hides the answer setting font & background to the same colour
until a second macro button is pressed to reveal the answer.

Sadly the answer can be 1 out due to the way random numbers are
created as decimals.

Cheers

John Taylor
Staffordshire
UK
 
On Thu, 18 Mar 2004 23:30:27 +0100, "Frank Kabel"


Hi, thanks again for your suggestion, sadly it produces ######## in
the cell.

Could I be very cheeky and forward you the file - it's 86 kb / It
would make it easier for you to se what I'm trying to do.

Regards

John
 
Hi
you can email me your sheet but before try changing the order of your
parameters to
=RANDBETWEEN(setup!D3,setup!B3)
RANDBETWEEN(upper,lower)
 
John:

I don't think you have a random number problem: I think the issue i
rounding.

Have a look at, for example, TRUNC(x) which returns the number x wit
its decimal part chopped off (not formatted, rounded or whatever, bu
amputated). Its behaviour will therefore be predictable.

Alternatively, have a look at INT which returns the bit before th
decimal point.

Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top