g+
g+ Communities
Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
<== Date ==> <== Thread ==>

Subject: RE: mask for bitwise operation in CALC record
From: <michael.abbott@diamond.ac.uk>
To: <haquin@ganil.fr>, <tech-talk@aps.anl.gov>, <anj@aps.anl.gov>
Date: Wed, 4 Jul 2012 09:06:12 +0000
Just noticed this conversation

From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of haquin
> Le 06/06/2012 18:23, Andrew Johnson a écrit :
> > On 2012-06-06 Dirk Zimoch wrote:
> >> I had assumed that the primary application for hex numbers would be bit
> >> masks. Signed masks do not make much sense but 0x80000000 does make
> >> sense. Maybe we should test for minus and then either call strtol() or
> >> strtoul().
> > Agreed, I will do that (currently writing lots of tests...).

I'm pretty sure it's always safe to strtoul(), the behaviour in the presence of a minus sign seems well defined in the man page I'm reading and I've certainly not encountered problems using it.

It's safer to use strtoul() rather than strtol() in general if you want modulo word size behaviour (which us low level engineers tend to), as I've encountered very unfriendly overflow behaviour from strtol().  Alas even strtoul() checks for overflow on negation :(


Replies:
Re: mask for bitwise operation in CALC record Andrew Johnson
References:
mask for bitwise operation in CALC record haquin
Re: mask for bitwise operation in CALC record Eric Norum
Re: mask for bitwise operation in CALC record Dirk Zimoch
Re: mask for bitwise operation in CALC record Andrew Johnson
Re: mask for bitwise operation in CALC record haquin

Navigate by Date:
Prev: FW: caQtDM Mezger Anton Christian
Next: RE: Consequences of the leap-second michael.abbott
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
Navigate by Thread:
Prev: Re: mask for bitwise operation in CALC record haquin
Next: Re: mask for bitwise operation in CALC record Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·