Not Yet Answered # Receiving a random float number between two float numbers

UncleLeroy 49 glutisnotasin firstPerson 761 arkoenig 340 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

2

Try something like this:

`x = low_number + (high_number - low_number) * (rand() / RAND_MAX) / 2.0;`

If you need more help, follow the policy of this forum, by writing some code yourself, and do not continue to ask for help without showing any effort on your part.

0

I have a similar problem. However this doesn't seem like a solution, because it only redistributes the possible random outputs so that they are spaced with regular intervals between low_number and high_number. There are still only RAND_MAX+1 different possibilities. What if I want the output to be ANY float?

Is there a function that does this? I've been trying to find for one several days without luck.

0

>>What if I want the output to be ANY float

rand() has a limit on the highest number it can return, specifically RAND_MAX. So if

you want to output any float number you need to adjust accordingly( or use a better RNG).

0

The problem is solvable in principle, but it isn't easy. Here's why.

Suppose you're trying to obtain a random number between 0.0 and 1.0, and you want the result to be uniformly distributed. That does not mean you want every possible floating-point number to appear equally likely, because the little tiny numbers close to 0, with large negative exponents, are much more closely spaced together than the bigger numbers near 1.

So if you want uniform distribution, and you also want every floating-point number to be possible as a result, you wind up with a whole bunch of tiny numbers that, because they're so close together, occur extremely rarely--but still have to be able to occur at all.

Figuring out how to do this reliably is far from easy, especially if your integer random-number generator isn't very good (as many of them aren't).

So before diving into this problem, you might want to think a bit about whether it's really what you want.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...