Code Monkey home page Code Monkey logo

conversions's Introduction

conversions

npm version Build Status Coverage Status npm downloads

dependencies Status devDependencies Status

Converts many different distance measures.

Install

npm install --save conversions

or

bower install --save conversions

Usage

conversions(value, fromUnit, toUnit)

Example

var conversions = require('conversions');
conversions(1000, 'metres', 'kilometres'); // equals 1
conversions(1000, 'm', 'km'); // equals 1

Supported Units

  • milimetres
  • centimetres
  • metres
  • kilometres
  • inches
  • feet
  • yards
  • miles

Aliases

It is possible to pass through other unit values for each unit, for example m|metre|metres|meter|meters or in|inch|inches

conversions's People

Contributors

blakeyc avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

twelve17

conversions's Issues

miles conversion lacks precision

Hello, and thank you for writing this library.

I noticed that one of my meters -> miles conversion was off:

I expected 24140.16 meters to equal 15 miles, precisely. But the library was returning 14.991039. Searching online, I found that 1 meter * 0.000621371 = 1 mile. However, the library has the conversion with slightly less precision, at 0.000621, which partially explains the difference in calculation.

I understand that, even with the greater precision, there are limitations when dealing with floating point arithmetic. However, with the extra three decimal points on the conversion number, I could round the result to a more precise decimal point. Would it be possible to append the additional three decimal values to the conversion?

All this being said, maybe the places I found the more accurate conversion value are off? I'd be curious to hear your input.

On the chance you find the suggestion acceptable, created a PR with the change.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.