Wordbit configuration using Expressions

8 Posts
5 Users
0 Likes
107 Views
(@s-mansoorarcinfo-com)
Posts: 13
Eminent Member
Topic starter
 

Hello everyone!

This is with refrence to KB638.
In version 15.0.2, word-to-bit conversion is working fine, but In version 15.2, it's not working as expected.
Suppose, I have taken 3 bits with variables:- @Wordbit.Bit00, @Wordbit.Bit01, @Wordbit.Bit02 and having Register as @Wordbit.Register01
Then the Expressions are :- @Wordbit.Register01>>00, @Wordbit.Register01>>01, @Wordbit.Register01>>02
So, in this case,
If @Wordbit.Register01 value is 1 then Bit00 is value is 1
If @Wordbit.Register01 value is 2 then both Bit00 & Bit01 values are 1, in this case, only Bit01 should be 1
If @Wordbit.Register01 value is 4 then both Bit00, Bit01 & Bit02 values are 1, in this case, only Bit02 should be 1
This case is showing an error in version 15.2 and working fine in version 15.0.2

I am attaching the project file.

 
Posted : 31/01/2022 11:09 am
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

Hello,

This issue has already been reported (SPR 70191) and will be fixed in version 15.2.1 (already in Nightly Build if needed)

BR

 
Posted : 31/01/2022 4:26 pm
e.mahaut
(@e-mahautarcinfo-com)
Posts: 270
Member Moderator
 

Hello,

Assuming the proper PcVue version is used, expressions on a variable
@Wordbit.Register01>>00
@Wordbit.Register01>>01
...
will work fine with values up to 65535 (16 bits)
will work fine with values up to 2147483647 (31 bits).

But if I am not mistaken, not from 2147483648 to 4294967295 (32 bits)
I guess it is because of Long type (-2,147,483,648 to +2,147,483,647)

The workaround could be the following:
(@Wordbit.Register01 & (2 POW 00)) >> 00 [or of course (@Wordbit.Register01 & (2 POW 0)) >> 0]
(@Wordbit.Register01 & (2 POW 01)) >> 01
...

It will work fine for values up to ~48 bits
SPR 70191 has no effect on this syntax. Can be used in 15.2 at once.

 
Posted : 03/02/2022 10:56 am
b.lepeuple
(@b-lepeuplearcinfo-com)
Posts: 149
Estimable Member
 

Hi Edouard,
Apart from being a workaround to the SPR #70191, this trick is worth being described in a KB article. A title such as "How to do bit shifting with long integers".
Thanks

 
Posted : 03/02/2022 3:00 pm
LM
 LM
(@l-micaudarcinfo-com)
Posts: 383
Member Admin
 

Thank you Benoît for this comment. It will be done soon.
I just would like to mention a new way to address requests regarding our KB, like new articles or mistakes report on old ones.
You can simply send an email to kb@arcinfo.odoo.com
Please provide the most possible details in the email.

 
Posted : 03/02/2022 4:48 pm
LM
 LM
(@l-micaudarcinfo-com)
Posts: 383
Member Admin
 

It took time but finally we have something published: KB1150

This post was modified 2 years ago by LM
 
Posted : 21/07/2022 2:07 am
b.lepeuple
(@b-lepeuplearcinfo-com)
Posts: 149
Estimable Member
 

Thank you Ludo.
Seeing the article content, don't you think we also need an SPR requesting the ability to extract all bits in 64-bit integers ?
Regards

 
Posted : 25/07/2022 2:27 pm
LM
 LM
(@l-micaudarcinfo-com)
Posts: 383
Member Admin
 

I agree. The two other people who took part in the proofreading of the article made the same request (Gilles and Edouard). Never 2 without 3 as we often say. So I created the spr 71220 (my postal code).

This reminds me of the magnificent legend of Sissa who asked a reward for having invented the chess game, a grain of wheat on the first square of the chessboard, then 2 grains on the 2nd square, then to double the number on the following squares... Which was not possible, indeed the number is too big. https://en.wikipedia.org/wiki/Sissa_(mythical_brahmin)

The total number of grains can be shown to be 264-1 or 18,446,744,073,709,551,615 (eighteen quintillion, four hundred forty-six quadrillion, seven hundred forty-four trillion, seventy-three billion, seven hundred nine million, five hundred fifty-one thousand, six hundred and fifteen, over 1.4 trillion metric tons), which is over 2000 times the annual world production of wheat 🙂
https://en.wikipedia.org/wiki/Wheat_and_chessboard_problem

 
Posted : 25/07/2022 7:12 pm