Benjamin Franksen wrote:
>
> Hi Folks,
>
> it's been quite a few weeks ago when one of my colleagues (Goetz
> Pfeiffer) had a problem with the ai record and another one (Jens Bergl)
> proposed a _very_ simple solution. The problem concerns the record's
> behavior when it does linear conversion from a 32 bit raw value to an
> analogue (double) value.
>
> The formula
>
> val = (rval + roff) * eslo + egul
>
> is implemented in the ai record support inside the function convert().
> Here, the first thing that happens is
>
> val = pai->rval + pai->roff;
>
> which leads to an overflow (and thus to an incorrect pai->val) if the
> raw value uses all 32 bits and the egul/eguf values are (for example)
> min(long) and max(long). This is because the calculation uses long
> arithmetic. A simple cast _before_ the calculation like
>
> val = (double)pai->rval + (double)pai->roff;
>
> solves the problem (one of the casts would do).
>
> Ben
This change will appear in the next release.
Marty Kraimer
- Replies:
- Re: ai record support has an error Benjamin Franksen
- References:
- ai record support has an error Benjamin Franksen
- Navigate by Date:
- Prev:
ai record support has an error Benjamin Franksen
- Next:
Subarray records with a minummum profile Hammonds, John
- 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:
ai record support has an error Benjamin Franksen
- Next:
Re: ai record support has an error Benjamin Franksen
- 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
|