Skip to content

jarvma18/js-ieee754

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IEEE754 for Javascript

Javascript library to convert values to decimal format and vice versa with IEEE754 standard.

To do:

  • Code refactoring/optimizing
  • Rounding
  • Values under 1
  • Underflow
  • Overflow
  • Handling the rounding errors
  • Error catching
  • Catching wrong inputs
  • Some additional test with jest
  • Add default value if no options are passed
  • Add error handling if no value is passed

How to use

const ieee754 = require(./ieee754);
const optionsWithReturnType = {mode: 'single', returnType: '16bitArray'};
const optionsWithoutReturnType = {mode: 'single'};

// Examples
console.log(ieee754.getDecimal([17530, 8192]);
// --> 1000.5
console.log(ieee754.getPrecision(1000.5, optionsWithReturnType));
// --> [17530, 8192]
console.log(ieee754.getPrecision(1000.5, optionsWithoutReturnType));
// --> 01000100011110100010000000000000
console.log(ieee754.getDecimal([0, 0]);
// --> 0
console.log(ieee754.getPrecision(0, optionsWithReturnType));
// --> [0, 0]
console.log(ieee754.getPrecision(0, optionsWithoutReturnType));
// --> 00000000000000000000000000000000

How to test with Jest

Install Jest to project

npm install

Run tests

npm test

Releases

No releases published

Packages

No packages published