Return-Path: william@bourbon.usc.edu
Delivery-Date: Sat Apr 21 02:44:23 2007
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on merlot.usc.edu
X-Spam-Level: 
X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,
	NO_REAL_NAME autolearn=ham version=3.1.3
Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75])
	by merlot.usc.edu (8.13.5/8.13.5) with ESMTP id l3L9iNEs026732
	for <cs551@merlot.usc.edu>; Sat, 21 Apr 2007 02:44:23 -0700
Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1])
	by bourbon.usc.edu (8.13.5/8.13.5) with ESMTP id l3L9iD2f024245
	for <cs551@merlot>; Sat, 21 Apr 2007 02:44:13 -0700
Message-Id: <200704210944.l3L9iD2f024245@bourbon.usc.edu>
To: cs551@merlot.usc.edu
Subject: Re: Proj Part 2 
Date: Sat, 21 Apr 2007 02:44:13 -0700
From: william@bourbon.usc.edu

Someone wrote:

  > I do the following
  > 
  > STOREPROB parsed from .ini file
  > 
  > float storeProbability = drand48()
  > 
  > if(storeProbability  < STOREPROB)
  > i cache the file
  > else
  > i dont
  > 
  > Given STOREPROB = 0
  > 
  > if storeProbability <<0.1 say 0.02 it satisifies the condition
  > and stores the file when in actual it should not. This happens
  > for very samll values returned by drand48()
  > 
  > I dont understand why??

My guess is that somehow your STOREPROB is not exactly zero.
You should print it out and see what it is exactly.

You should make it exactly zero when you read your INI file.
Don't read it as a floating point number and just read it as
a string.  Check if the string is "0", if not, then call
sscanf() or atof() to convert it into a float or double.

By the way, I rarely use float in my code.  Use double instead
of float.  With the kind of processors we have these days,
extra steps has to be taken to convert doubles into floats.
So, computation with doubles is actually faster than floats.
--
Bill Cheng // bill.cheng@usc.edu <URL:http://merlot.usc.edu/william/usc/>
