Hi John,
On 07/01/2015 07:32 AM, Priller, John wrote:
> I have code that uses epicsScanDouble to convert a string-representation
> of floating point numbers to actual floating-point, and I've found
> there's a behavior change from R3.14.12.2 to R3.15 (either .1 or .2)
I am the guilty party for that change.
> Skimming the source it appears that epicsScanDouble is now a macro
> calling epicsParseDouble with a units pointer of NULL. If I call
> epicsParseDouble directly with units=NULL this does indeed fail, but if
> I pass it a valid pointer it then succeeds.
>
> So, question: was this an intentional change, that units/etc off the end
> of the number string now cause epicsScanDouble to fail? I can
> #if/#else the code to call epicsParseDouble if it's available, and I
> guess I'll have to do that for now, but that's the sort of version
> dependency I'd like to avoid if at all possible.
I was intentionally tightening up the conversions so they report an
error for numbers with typos in them ("6,02e+23") rather than silently
accept just the numeric part before the typo. The new epicsParse*()
routines make it easy to check the trailing units strings — for example
3.15 uses this to allow periodic scan rates to be specified in seconds,
minutes, hours or even Hertz.
Maybe I should have kept the behaviour of the epicsScan*() routines the
same, but 3.15 is a major release so it doesn't promise 100% backwards
compatibility. I would also rather leave the tighter conversion
behaviour in place.
Does your application know what the units strings are allowed for those
inputs? I would suggest writing code something like this, checking for
the presence of the macro rather than something in epicsVersion.h to
have it work on both:
#ifdef epicsScanDouble
/* Macro, so epicsParseDouble() is available */
... call epicsParseDouble, check return status and unit string
#else
... call epicsScanDouble, check return status
#endif
Note that the status value returned by the epicsParse*() routines tells
you what kind of error it found which you can report to the user,
whereas epicsScan*() just returns pass/fail.
HTH,
- Andrew
--
Light thinks it travels faster than anything but it is wrong.
No matter how fast light travels, it finds the darkness has
always got there first, and is waiting for it.
-- Terry Pratchett, Reaper Man
- References:
- epicsScanDouble behavior change in R3.15 Priller, John
- Navigate by Date:
- Prev:
epicsScanDouble behavior change in R3.15 Priller, John
- Next:
mbbiDirect record bits into ai record Deepika Thakur
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
<2015>
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
epicsScanDouble behavior change in R3.15 Priller, John
- Next:
mbbiDirect record bits into ai record Deepika Thakur
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
<2015>
2016
2017
2018
2019
2020
2021
2022
2023
2024
|