- #1

- 223

- 54

A can be computed from B like this

Code:

```
Input: BOOL b, OBJECT B
A=(B<<5)
if NOT b then
A=[A OR 0xFF]
```

Code:

`Input: BOOL b, OBJECT A`

Code:

```
B=A>>5
if NOT b then
B= ?
```

Code:

```
if NOT b then
B=?
B=A>>5
```

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

In summary, you can't compute B from A using the code you provided, and you might not be able to find an inverse OR operator that will work.f

- #1

- 223

- 54

A can be computed from B like this

Code:

```
Input: BOOL b, OBJECT B
A=(B<<5)
if NOT b then
A=[A OR 0xFF]
```

Code:

`Input: BOOL b, OBJECT A`

Code:

```
B=A>>5
if NOT b then
B= ?
```

Code:

```
if NOT b then
B=?
B=A>>5
```

- #2

Mentor

- 37,232

- 9,399

It's not clear from your explanation what you're trying to do here. Also, because you haven't indicated what type A is or what the underlying type is for B (i.e., the number of bits), it's hard for me to determine what the code above will produce.I have 2 variables A and B.

A can be computed from B like this

Code:`Input: BOOL b, OBJECT B A=(B<<5) if NOT b then A=[A OR 0xFF]`

All I can say for sure is that the low 8 bits of A will be set to 0xFF.

Medicol said:Now I would like to compute B from the above code

It can be eitherCode:`Input: BOOL b, OBJECT A`

orCode:`B=A>>5 if NOT b then B= ?`

I am not sure which way as well as the correct inverse OR operator it is that I'm seeking, I'm so confused..Code:`if NOT b then B=? B=A>>5`

- #3

- 15,462

- 688

You can't, assuming that your OBJECTs are integer-like objects and your OR is a bit-wise or. The problem is that your function that maps B values to A values is not a one to one, onto mapping. One problem occurs with the computation when b is false. Any value between of 0 and 7 maps to 255, and value between 8 and 15 maps to 511, and so on. So which of the eight possible values to you want 255 to map to?Now I would like to compute B from the above code

Another problem: What if A is 1? There is no (b,B) pair that produces a value of 1.

- #4

- 223

- 54

My problem was something like this

A<<=5;

B=(A|=0x80);

then

B&=**0x7F;**

A=(B=>>5);

:D Have a good day!

A<<=5;

B=(A|=0x80);

then

B&=

A=(B=>>5);

:D Have a good day!

Share:

JavaScript
Spread operator in javascript

- Replies
- 2

- Views
- 769

- Replies
- 29

- Views
- 1K

- Replies
- 3

- Views
- 177

- Replies
- 1

- Views
- 811

- Replies
- 2

- Views
- 894

- Replies
- 22

- Views
- 1K

- Replies
- 18

- Views
- 1K

- Replies
- 53

- Views
- 3K

- Replies
- 23

- Views
- 1K

- Replies
- 7

- Views
- 2K