[comp.lang.c] drand48

root@kunivv1.sci.kun.nl (Privileged Account) (03/21/90)

Does anybody know how the drand48 function of C works?
We have got problems with it,
when we assign the result of the drand48 function to a variable and
print it afterwards, the value printed is not between 0 and 1.
But, when we instead print the result of drand48 directly, the result is
between 0 and 1.

Anyone got any solutions?
Please mail me directly because I don't read this group regularly.

Thanks anyway, for reading this message.

                                                     John Graat,
                                                     ttn8@erato.cs.kun.nl
                                                     University of Nijmegen,
                                                     The Netherlands.

bruno@hpfcso.HP.COM (Bruno Melli) (03/23/90)

/ hpfcso:comp.lang.c / root@kunivv1.sci.kun.nl (Privileged Account) /  6:00 am  Mar 21, 1990 /

> when we assign the result of the drand48 function to a variable and
> print it afterwards, the value printed is not between 0 and 1.
> But, when we instead print the result of drand48 directly, the result is
> between 0 and 1.

make sure you have a line like

double drand48();

in your definitions before you call the function. 

Unless told otherwise the compiler assumes that drand48() returns an int.

bruno.

ce3wa3bh@maccs.dcss.mcmaster.ca (Eric Ho) (03/22/91)

Could someone teach how to invoke the C Library function drand48 () (I am
working on a SUN 4/280).  Thanks in advance!  Please reply via e-mail.


-- 
Cheers,                                                9041477@mcmaster.bitnet
Eric Ho					       ce3wa3bh@maccs.dcss.mcmaster.ca
McMaster University, Ontario, Canada        ...uunet!utai!utgpu!maccs!ce3wa3bh