![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
another question... Is there any way to get a 12 bit int via union ?... never mind how ))))
SZY: 9-15 bit int ideally, sign to allocate not a problem, i.e. it is possible unsigned int (in last builds of MQL learnedunsigned int, it is possible instead of uint to use )
I don't understand it ... help!)))
I figured out that I can allocate some needed bits this way:
where the most significant bit would be now , to determine the sign of the number... don't know, i.e. ideally it should be a function
ideally it should be a template to use such structures at all:
So again I don't get it...help! help!)))
I figured out that I can allocate some of the bits I need:
where the highest bit would be now to determine the sign of the number... don't know, i.e. ideally it should be a function
ideally it should be a template to use such structures at all:
See. The mask is the significant part of the number, i.e., for int, you have to shift a bit further, since the high bit you have the sign means. <<pos is a mess. As in your case, you will take high bits of int by this mask, while you need low bits))).
For signed integers, you must separately take significant part, separately take high bit (sign), then shift high bit to needed position and use bitwise OR to combine them. Example for int-> 4 bits
int mean4=0xFFFFFFFF>>29
int sign16=1<<31
int sign4=1<3
Now int->int4 watch your hands:
1. we have int val
2. int sign=(val&sign16)>>28.
Here we have taken the sign of our number and shifted it to the right position (the most significant bit in int4)
3. mean3val=val&mean4
Here we have got the three least significant bits (meaningful part) through a mask, the rest is clipped.
4. int out=sign|mean3val
And here we have combined the sign with the significant part. Now we have 4 low-order bits, in which bit 4 is the sign, and bits 1 to 3 are the significant part, all bits above 4 have a value of 0. The range of values is -8...7 And yes, if 8 is fed in, there will be no 7 and it will be 0, as everything will just cut off.
It's easier to shift by the right number of bits and use 1 for the mask. At least it is more obvious.
Sign definition: (a>>31)&1 - if 1, then minus, if 0, then plus.
I can make significant bits out of int with a "head-on" solution, but I can't make a universal solution... I can't! (((
It is highly probable that I have not explained how and where I want to go
there are 4 bytes int / uint, and there is my dataset, which I want to unpack in the optimizer
let's assume I succeeded in packing it this way:
what types I need int_XXX, I have not yet estimated
but I want to have usability in the form of this code
Has no one found my error yet? ))))
Tip: uint all masks should be)))
I can make significant bits out of int with a "head-on" solution, but I can't make a universal solution... I can't! (((
It is highly probable that I have not explained how and where I want to go
there are 4 bytes int / uint, and there is my dataset, which I want to unpack in the optimizer
let's assume I succeeded in packing it this way:
what types I need int_XXX, I have not yet estimated
but I want to have a usability in the form of the following code
o - indent (bits), l - length (number of bits), value to add, r - where to add
But I haven't tested it.
Because you are not overriding a virtual function, you are using overloading.
There's clearly something wrong here
There's obviously something wrong here.
Make the method a template and access it
Make the method a template and access it
That's a laifhack!!!
ps: +1 way to write something that will just stop working with the update when they tweak that loafhack
That's a loophole!!!
ps: +1 way to write something that will just stop working with the update when they tweak this loafhack