gchq/CyberChef · error · OperationError

Input is not a multiple of ${byteSize}

Error message

Input is not a multiple of ${byteSize}

What it means

To Float interprets the input bytes as a sequence of IEEE-754 values, each 4 bytes (single precision) or 8 bytes (double precision) depending on the size argument. The guard rejects any input whose total length is not an exact multiple of the chosen word size, because a partial trailing word cannot be decoded.

Source

Thrown at src/core/operations/ToFloat.mjs:68

                "value": DELIM_OPTIONS
            }
        ];
    }

    /**
     * @param {byteArray} input
     * @param {Object[]} args
     * @returns {string}
     */
    run(input, args) {
        const [endianness, size, delimiterName] = args;
        const delim = Utils.charRep(delimiterName || "Space");
        const byteSize = size === "Double (8 bytes)" ? 8 : 4;
        const isLE = endianness === "Little Endian";
        const mLen = byteSize === 4 ? 23 : 52;

        if (input.length % byteSize !== 0) {
            throw new OperationError(`Input is not a multiple of ${byteSize}`);
        }

        const output = [];
        for (let i = 0; i < input.length; i+=byteSize) {
            output.push(ieee754.read(input, i, isLE, mLen, byteSize));
        }
        return output.join(delim);
    }

}

export default ToFloat;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Pad or trim the input so its length is a multiple of the selected word size (4 or 8).
  2. Switch the size to Double if the data is 8-byte-aligned, or Single if 4-byte-aligned.
  3. Remove any stray delimiter bytes before To Float.

Example fix

// before: input length 5, size = "Single (4 bytes)" -> 5 % 4 != 0, throws
// after:  input length 8 (pad/trim), size = "Single (4 bytes)" -> 2 floats decode
Defensive patterns

Strategy: validation

Validate before calling

const byteSize = size === "Double (8 bytes)" ? 8 : 4;
if (input.length % byteSize !== 0) {
  throw new Error(`Input length ${input.length} not a multiple of ${byteSize}`);
}

Type guard

const isAligned = (len, size) => size === "Double (8 bytes)" ? len % 8 === 0 : len % 4 === 0;

Try / catch

try { toFloat(input, [endianness, size, delim]); }
catch (e) { if (/not a multiple/.test(e.message)) { input = input.slice(0, Math.floor(input.length / byteSize) * byteSize); } else throw e; }

Prevention

When it happens

Trigger: Feeding a byte array whose length is not divisible by 4 (single) or 8 (double). Example: 5 bytes with size = Single, or 9 bytes with size = Double.

Common situations: Truncated ciphertext/data; leftover delimiter bytes from a previous 'From Hex' step that stripped spaces inconsistently; wrong size selection for the source format.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/68f38491a45bf8e7. Report an issue: GitHub.