All Questions



randf() question

Im wondering how many characters randf() has after " . ", is it only 1  where it can only generate  0.3 for example ? Or is it generating 0.31325

  • Nathan Lovato replied

    It will not generate a rounded number if that is the question. The generated number will not have a fixed number of decimals.

    On the computer, all numbers are represented by series of zeros and ones. Your decimal number depends on the programming language. it depends on how much memory the computer allocates to 1 number.

    With your typical float, you can go up to over a dozen decimals, but then you also need to take into account the fact that decimal numbers on computers aren't precise.