MESSAGE
DATE | 2012-02-25 |
FROM | Ruben Safir
|
SUBJECT | Re: [NYLXS - HANGOUT] Re: c++ question about decimals
|
From owner-hangout-outgoing-at-mrbrklyn.com Sat Feb 25 18:14:12 2012 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by www2.mrbrklyn.com (Postfix) id D7479100BD8; Sat, 25 Feb 2012 18:14:11 -0500 (EST) Delivered-To: hangout-outgoing-at-www2.mrbrklyn.com Received: by www2.mrbrklyn.com (Postfix, from userid 28) id C43B7100BF2; Sat, 25 Feb 2012 18:14:11 -0500 (EST) Delivered-To: hangout-at-mrbrklyn.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by www2.mrbrklyn.com (Postfix) with ESMTP id 19D0B100BD8 for ; Sat, 25 Feb 2012 18:14:10 -0500 (EST) Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 8434D32702; Sat, 25 Feb 2012 18:12:29 -0500 (EST) Received: by panix2.panix.com (Postfix, from userid 20529) id 6C26B33C52; Sat, 25 Feb 2012 18:12:29 -0500 (EST) Date: Sat, 25 Feb 2012 18:12:29 -0500 From: Ruben Safir To: hangout-at-mrbrklyn.com Cc: hangout-at-nylxs.com Subject: Re: [NYLXS - HANGOUT] Re: c++ question about decimals Message-ID: <20120225231229.GA10378-at-panix.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: owner-hangout-at-mrbrklyn.com Precedence: bulk Reply-To: hangout-at-mrbrklyn.com
On Fri, Feb 24, 2012 at 09:33:14AM -0500, Paul Robert Marino wrote: > actually after looking into this further what i really need to do is > grab just the remainder of the result of dividing 2 numbers I think > fmod is the answer im looking for >
What you have to remember is that the conversion from ints to floats is OK but floats to a smaller digit has this long list of possible behaviors and some are underfined.
if you want the remainder, the mod opertator is extremely useful and I use it for psuedorandom generation, but you need to make sure everything is a float of appropriate size.
Ruben
> > On Fri, Feb 24, 2012 at 12:48 AM, Paul Robert Marino > wrote: > > my C programmings a little rusty and i could use some help > > im working on a patch for keepalived i have to modify a portion of the > > code that type casts several variables as a unsigned long however I > > need to change it to an equivalent the will store it with a decimal > > with 2 points of precision, and if possible wont change how other > > parts of the code use the same functions with whole numbers does any > > one have any suggestions. > > > > by the way in case any one is wondering im working on implementing > > centisecond (hundredth) of a second intervals for VRRP per the RFC for > > VRRPv3 http://tools.ietf.org/html/rfc5798 > > so far its going well but there are a few points in the code that are > > doing crazy things like setting a sleep timer to 0 seconds which is > > what I'm trying to fix now. that being said the rest of the patch > > works great i was able to cut my interface failover times in nearly > > down from 8 to less than 3 seconds total.
|
|