mirror of
https://github.com/gchq/CyberChef.git
synced 2026-03-26 16:51:26 -07:00
Add ToIEEEBinary Operation
This commit is contained in:
parent
02cc9a1ccf
commit
443eabf160
1 changed files with 46 additions and 0 deletions
46
src/core/operations/ToIEEEBinary.mjs
Normal file
46
src/core/operations/ToIEEEBinary.mjs
Normal file
|
|
@ -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.<br><br>
|
||||
Example: <code>2</code> becomes
|
||||
<code>0 10000000000 0000000000000000000000000000000000000000000000000000</code>.`;
|
||||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue