Experimental Physics and Industrial Control System
The '-' flag is already used to allow negative hex numbers like "-0x123f"
Dirk
> Am 15.09.2025 um 18:16 schrieb Dmitry Yu. Bolkhovityanov <D.Yu.Bolkhovityanov at inp.nsk.su>:
>
> Hi Dirk!
>
> Isn't '+' counter-intuitive? The word "plus" is usually associated with positive numbers, while negative numbers are associated with '-'.
>
> Is '-' flag already used for something completely different in input parsing?
>
>
> With best regards,
> Dmitry
>
>
>
>> On Mon, 15 Sep 2025, Zimoch, Dirk via Tech-talk wrote:
>>
>> Hello Eddy
>>
>> I have implemented your request. See latest commit 5ae38a08.
>> https://urldefense.us/v3/__https://github.com/paulscherrerinstitute/StreamDevice/commit/5ae38a08__;!!G_uCfscf7eWS!cAw9XzrsbzJkeIaTJbCHGITiBrLKBpAF9UPGNJsfAFSd7i_i4yL_A9_NL8SDU87mR-hs6DRqHgTTqdb0ORwuRDxFFQ$
>>
>> Now, if using the + flag ("%+x" or "%+X"), the value will be interpreted as a
>> signed hex number. That means it will be sign extended if the most significant
>> hex digit is 8 or higher. But if width is given, width characters must have been
>> read:
>>
>> in "%+x"; sign extends "80", " 9", "0xf", "abcd" but not "0x0f" or "0fed"
>> in "%+4x"; sign extends "abcd" and "0xf0" but not "abc" or "0xf"
>>
>> Dirk
>>
>>
>>> On Mon, 2025-09-15 at 10:28 +0200, Zimoch Dirk wrote:
>>> Hello Eddy
>>>
>>> Signed %x input is currently not supported by StreamDevice but it is definitely
>>> useful to have. I have to think how to implement it and which flag to use to
>>> signal the switch from normal unsigned %x.
>>>
>>> Dirk
>>>
>>> On Mon, 2025-09-15 at 08:04 +0000, Blomley, Edmund (IBPT) via Tech-talk wrote:
>>>> Hey,
>>>>
>>>> So my device sends me a 4 bit hex which I convert to a float using an ai record and linear conversion with ESLO.
>>>> Let?s ignore the conversion for now, the number needs to be treated as a signed long, so I need to get the 2?s complement:
>>>>
>>>> 07D0 -> 2000
>>>> F6F5 -> -2315
>>>>
>>>> Is there a way to do this directly with streamdevice?
>>>> If not, I would need to read in the raw long and convert it myself. What is the best approach to do the conversion with records?
>>>> So far I would do:
>>>>
>>>> field(CALC, "65535 - A + 1") with A being the raw long.
>>>> Cheers
>>>> eddy
>>>>
>>
- References:
- Parse Hex into signed number with streamdevice? Blomley, Edmund (IBPT) via Tech-talk
- Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk
- Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk
- Navigate by Date:
- Prev:
Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk
- Next:
Re: Help with bumpless IOC reboot, record linking and initialization concepts Ralph Lange via Tech-talk
- 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
<2025>
- Navigate by Thread:
- Prev:
Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk
- Next:
Re: Help with bumpless IOC reboot, record linking and initialization concepts Ralph Lange via Tech-talk
- 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
<2025>