import type { FnU3 } from "@thi.ng/api" ; import type { Bit } from "./api.js" ; import { defMask } from "./mask.js" ; param x param bit export const bitClear = ( x , bit ) => ( x & ~ ( 1 << bit ) ) >>> 0 ; param x param bit export const bitFlip = ( x , bit ) => ( x ^ ( 1 << bit ) ) >>> 0 ; param x param bit export const bitSet = ( x , bit ) => ( x | ( 1 << bit ) ) >>> 0 ; export const bitSetWindow = ( x , y , from , to ) => { const m = defMask ( from , to ) ; return ( x & ~ m ) | ( ( y << ( 1 << from ) ) & m ) ; } ; export const bitClearWindow = ( x , from , to ) => x & ~ defMask ( from , to ) ;