{"record":{"id":"68f38491a45bf8e7","repo":"gchq/CyberChef","slug":"input-is-not-a-multiple-of-bytesize","errorCode":null,"errorMessage":"Input is not a multiple of ${byteSize}","messagePattern":"Input is not a multiple of (.+?)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ToFloat.mjs","lineNumber":68,"sourceCode":"                \"value\": DELIM_OPTIONS\n            }\n        ];\n    }\n\n    /**\n     * @param {byteArray} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        const [endianness, size, delimiterName] = args;\n        const delim = Utils.charRep(delimiterName || \"Space\");\n        const byteSize = size === \"Double (8 bytes)\" ? 8 : 4;\n        const isLE = endianness === \"Little Endian\";\n        const mLen = byteSize === 4 ? 23 : 52;\n\n        if (input.length % byteSize !== 0) {\n            throw new OperationError(`Input is not a multiple of ${byteSize}`);\n        }\n\n        const output = [];\n        for (let i = 0; i < input.length; i+=byteSize) {\n            output.push(ieee754.read(input, i, isLE, mLen, byteSize));\n        }\n        return output.join(delim);\n    }\n\n}\n\nexport default ToFloat;\n","sourceCodeStart":50,"sourceCodeEnd":81,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ToFloat.mjs#L50-L81","documentation":"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.","triggerScenarios":"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.","commonSituations":"Truncated ciphertext/data; leftover delimiter bytes from a previous 'From Hex' step that stripped spaces inconsistently; wrong size selection for the source format.","solutions":["Pad or trim the input so its length is a multiple of the selected word size (4 or 8).","Switch the size to Double if the data is 8-byte-aligned, or Single if 4-byte-aligned.","Remove any stray delimiter bytes before To Float."],"exampleFix":"// before: input length 5, size = \"Single (4 bytes)\" -> 5 % 4 != 0, throws\n// after:  input length 8 (pad/trim), size = \"Single (4 bytes)\" -> 2 floats decode","handlingStrategy":"validation","validationCode":"const byteSize = size === \"Double (8 bytes)\" ? 8 : 4;\nif (input.length % byteSize !== 0) {\n  throw new Error(`Input length ${input.length} not a multiple of ${byteSize}`);\n}","typeGuard":"const isAligned = (len, size) => size === \"Double (8 bytes)\" ? len % 8 === 0 : len % 4 === 0;","tryCatchPattern":"try { toFloat(input, [endianness, size, delim]); }\ncatch (e) { if (/not a multiple/.test(e.message)) { input = input.slice(0, Math.floor(input.length / byteSize) * byteSize); } else throw e; }","preventionTips":["Verify byte alignment before converting.","Match the size argument to the data's word width.","Trim stray delimiter bytes from upstream steps."],"tags":["float","ieee754","alignment","validation","bytes"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}