# Class RANSEncodingSymbol

java.lang.Object
htsjdk.samtools.cram.compression.rans.RANSEncodingSymbol

public final class RANSEncodingSymbol extends Object
Encoding state for a single symbol in the rANS codec. Fields are package-private to allow the encode loops in `RANSNx16Encode` and `RANS4x8Encode` to inline the renormalization and state-update arithmetic directly, avoiding method call overhead in the hot inner loop.

## Constructor Summary

Constructors
Constructor
Description
`RANSEncodingSymbol()`

## Method Summary

Modifier and Type
Method
Description
`long`
`putSymbol4x8(long r, byte[] out, int[] posHolder)`
byte[] variant for 4x8 encoding — writes backwards, decrementing posHolder[0].
`long`
`putSymbolNx16(long r, byte[] out, int[] posHolder)`
byte[] variant for Nx16 encoding — writes backwards (decrementing posHolder[0]).
`void`
`reset()`
Reset all encoding parameters to zero.
`void`
`set(int start, int freq, int scaleBits)`
Initialize encoding parameters for a symbol given its position in the frequency table.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### RANSEncodingSymbol

public RANSEncodingSymbol()

## Method Details

### reset

public void reset()
Reset all encoding parameters to zero.

### set

public void set(int start, int freq, int scaleBits)
Initialize encoding parameters for a symbol given its position in the frequency table. Computes the reciprocal frequency and bias needed for fast integer division during encoding.

Parameters:
  `start` - cumulative frequency of all preceding symbols
  `freq` - frequency of this symbol (must be > 0)
  `scaleBits` - log2 of the total frequency sum

### putSymbolNx16

public long putSymbolNx16(long r, byte[] out, int[] posHolder)
byte[] variant for Nx16 encoding — writes backwards (decrementing posHolder[0]). Renormalization bytes are written so the final memory layout is little-endian (LSB at lower address), matching htslib's RansEncPutSymbol output format.

### putSymbol4x8

public long putSymbol4x8(long r, byte[] out, int[] posHolder)
byte[] variant for 4x8 encoding — writes backwards, decrementing posHolder[0].