#JavaScript (ES6), (削除) 92 (削除ここまで)(削除) 87 (削除ここまで) 81
JavaScript (ES6), (削除) 92 (削除ここまで)(削除) 87 (削除ここまで) 81
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6), (削除) 92 (削除ここまで)(削除) 87 (削除ここまで) 81
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
JavaScript (ES6), (削除) 92 (削除ここまで)(削除) 87 (削除ここまで) 81
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6) 81, (削除) 92 (削除ここまで) (削除) 87 92 (削除ここまで) 81
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6) 81 (削除) 87 92 (削除ここまで)
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6), (削除) 92 (削除ここまで) (削除) 87 (削除ここまで) 81
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6) 8781 (削除) 9287 92 (削除ここまで)
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
((w^w*2^w*4^w/2)&4)|&4|
((w/8^w^w*2^w/16)&2)|&2|
((w/16^w/4^w^w/64)&1)
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2)))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6) 87 (削除) 92 (削除ここまで)
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
((w^w*2^w*4^w/2)&4)|
((w/8^w^w*2^w/16)&2)|
((w/16^w/4^w^w/64)&1)
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2)))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]
#JavaScript (ES6) 81 (削除) 87 92 (削除ここまで)
Function getting and returning an integer in MSB.
The implementation is straightforwrd following @randomra comment:
- calc p3wrong|p2wrong|p1wrong (line 2,3,4)
- use it as a bit mask to flip the incorrect bit (line 1),
- then return just the data bits (last line)
F=w=>(w^=128>>(
(w^w*2^w*4^w/2)&4|
(w/8^w^w*2^w/16)&2|
(w/16^w/4^w^w/64)&1
))&7|w/2&8
Test In Frefox/FireBug console
;[0b1110000,0b1100000,0b1111011,0b0110001,
0b1011011,0b0101001,0b1010000,0b0100010]
.map(x=>x.toString(2)+'->'+F(x).toString(2))
Output
["1110000->1000", "1100000->1000", "1111011->1111", "110001->1011", "1011011->1010", "101001->1", "1010000->1000", "100010->10"]