BinOp
이 페이지에서

BinOp

타입, IR 분류

The operator tag on Expr.binop: arithmetic (+ - * /), remainder (%) and bitwise.

import type { BinOp } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

type BinOp = '+' | '-' | '*' | '/' | '%' | '&' | '|' | '^' | '<<' | '>>';

설명

Each is spelled the same way in WGSL and GLSL and evaluated the same way by the CPU backend. On floats % is a truncating remainder, so its sign follows the dividend: WGSL’s native % behaves this way, and the GLSL backend writes a - b * trunc(a / b) because GLSL ES 3.00’s own % is integer-only. When a negative operand is possible and a floor modulo is wanted, use mod, which is floor-mod on every target; the .mod() method on Node emits this truncating %. For integer operands the CPU backend follows WGSL: two’s-complement wrap, truncating / with x / 0 = x and x % 0 = 0, and <</>> as logical shifts on u32, with >> on i32 an arithmetic (sign-preserving) shift.

함께 보기

소스

src/core/ir/nodes.ts, 28행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고