From 443eabf160bf448934cde7670976e1592c0ed731 Mon Sep 17 00:00:00 2001 From: atsiv sivat Date: Sat, 31 Jan 2026 15:54:27 +0000 Subject: [PATCH] Add ToIEEEBinary Operation --- src/core/operations/ToIEEEBinary.mjs | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/core/operations/ToIEEEBinary.mjs diff --git a/src/core/operations/ToIEEEBinary.mjs b/src/core/operations/ToIEEEBinary.mjs new file mode 100644 index 000000000..db93e920e --- /dev/null +++ b/src/core/operations/ToIEEEBinary.mjs @@ -0,0 +1,46 @@ +/** + * @author atsiv1 + * @copyright Crown Copyright 2019 + * @license Apache-2.0 + */ + +import Operation from "../Operation.mjs"; +import { ToIEEE754Float64 } from "../lib/IEEEBinary.mjs"; + +/** + * To IEEEBinary operation + */ +class ToIEEEBinary extends Operation { + /** + * ToIEEEBinary constructor + */ + constructor() { + super(); + + this.name = "To IEEEBinary"; + this.module = "Default"; + this.description = ` + Converts a decimal number into IEEE-754 double-precision float64.

+ Example: 2 becomes + 0 10000000000 0000000000000000000000000000000000000000000000000000.`; + this.infoURL = "https://en.wikipedia.org/wiki/IEEE_754"; + this.inputType = "string"; + this.outputType = "string"; + this.args = []; + } + + /** + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + run(input, args) { + if (!input || input.trim().length === 0) { + return ""; + } + + return ToIEEE754Float64(input); + } +} + +export default ToIEEEBinary;