mirror of
https://github.com/gchq/CyberChef.git
synced 2026-03-27 01:01:23 -07:00
Add FromIEEEBinary Operation
This commit is contained in:
parent
9706fbb10b
commit
02cc9a1ccf
1 changed files with 47 additions and 0 deletions
47
src/core/operations/FromIEEEBinary.mjs
Normal file
47
src/core/operations/FromIEEEBinary.mjs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* @author atsiv1
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import { FromIEEE754Float64 } from "../lib/IEEEBinary.mjs";
|
||||
|
||||
/**
|
||||
* From IEEEBinary operation
|
||||
*/
|
||||
class FromIEEEBinary extends Operation {
|
||||
/**
|
||||
* FromIEEEBinary constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "From IEEEBinary";
|
||||
this.module = "Default";
|
||||
this.description = `
|
||||
Converts a 64-bit IEEE-754 binary64 representation (float64)
|
||||
into its exact decimal value.<br><br>
|
||||
Example: <code>0 10000000010 0100000000000000000000000000000000000000000000000000</code>
|
||||
becomes <code>10</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 FromIEEE754Float64(input);
|
||||
}
|
||||
}
|
||||
|
||||
export default FromIEEEBinary;
|
||||
Loading…
Add table
Add a link
Reference in a new issue