Appearance
helix / Fixed
Class: Fixed โ
Defined in: core/frontend/nodes/fixed.ts:32
A fixed-point number: one integer Score holding realValue x scale.
Scoreboards are integers, so multiply and divide must rebalance the scale; the method names handle that. scaleScore is an optional slot holding scale that saves one command per multiply below 26.3 (the scoreboard can't use a literal operand).
Holds a reference to an existing slot, emits into the ambient context (or ctx), and chains. Division floors toward -infinity.
Constructors โ
Constructor โ
new Fixed(
score,scale,scaleScore?):Fixed
Defined in: core/frontend/nodes/fixed.ts:33
Parameters โ
score โ
scale โ
number
scaleScore? โ
Score<number>
Returns โ
Fixed
Properties โ
scale โ
readonlyscale:number
Defined in: core/frontend/nodes/fixed.ts:35
scaleScore? โ
readonlyoptionalscaleScore?:Score<number>
Defined in: core/frontend/nodes/fixed.ts:36
score โ
readonlyscore:Score
Defined in: core/frontend/nodes/fixed.ts:34
Methods โ
add() โ
add(
other,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:74
this += other - same-scale addition is just integer +=.
Parameters โ
other โ
Score<number> | Fixed
ctx? โ
Returns โ
this
assign() โ
assign(
other,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:68
this = other (same scale; other may be a raw Score already at this scale).
Parameters โ
other โ
Score<number> | Fixed
ctx? โ
Returns โ
this
clamp() โ
clamp(
lo,hi,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:128
Clamp the underlying score into [lo, hi] (< hi then > lo).
Parameters โ
lo โ
hi โ
ctx? โ
Returns โ
this
divide() โ
divide(
divisor,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:104
Divides by divisor, multiplying by the scale first so small results don't floor to zero.
Parameters โ
divisor โ
Score<number> | Fixed
ctx? โ
Returns โ
this
gain() โ
gain(
k,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:113
Multiply by a unitless factor k (*= k); the scale is unchanged.
Parameters โ
k โ
ctx? โ
Returns โ
this
mul() โ
mul(
other,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:92
Multiplies by a same-scale other, dividing the extra scale back out.
Parameters โ
other โ
Fixed
ctx? โ
Returns โ
this
negate() โ
negate(
negOne?,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:86
Negates in place. Below 26.3 this needs a -1 slot in negOne; 26.3+ ignores it.
Parameters โ
negOne? โ
Score<number>
ctx? โ
Returns โ
this
read() โ
read(
who,path,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:44
Reads the number at path on who into this, at this scale.
Parameters โ
who โ
path โ
ctx? โ
Returns โ
this
reduce() โ
reduce(
k,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:122
Divides by a unitless integer k; scale unchanged. A plain floor divide, for ratio constants.
Parameters โ
k โ
ctx? โ
Returns โ
this
store() โ
store(
who,path,type?,factor?,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:53
Writes this to path on who as a real number, times a unitless factor.
Parameters โ
who โ
path โ
type? โ
StoreNumType = "double"
factor? โ
number = 1
ctx? โ
Returns โ
this
sub() โ
sub(
other,ctx?):this
Defined in: core/frontend/nodes/fixed.ts:80
this -= other - same-scale subtraction is just integer -=.
Parameters โ
other โ
Score<number> | Fixed
ctx? โ
Returns โ
this