Rand() and RAND_MAX incompatibilty

  • From: "PuntatoreNullo" < >
  • To:
  • Subject: Rand() and RAND_MAX incompatibilty
  • Date: Fri, 11 Jan 2013 10:05:26 -0500

Hello everyone!

I had a weird problem with the use of the function rand. 

My aim was to build a library (dll) in which a function randomly extracts a 
number between 0 and 1. So I just implemented rand()/(double)RAND_MAX, but 
the extracted numbers were only in a subset of [0,1].

So I discovered that, while the function rand extracted numbers in [0, 
32767], RAND_MAX was 2147483647 (so I just solved by creating a constant 
CUSTOM_RAND_MAX).

What the problem is due to? (I'm using NetBeans 7.0 under Windows XP)

Regards






Rand() and RAND_MAX incompatibilty

PuntatoreNullo 01/11/2013

Project Features

About this Project

CND was started in November 2009, is owned by Leonid Lenyashin, and has 130 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close