gentooboontoo / js-quantities

JavaScript library for quantity calculation and unit conversion
http://gentooboontoo.github.io/js-quantities/
MIT License
396 stars 102 forks source link

Incorrect tablespoon conversion #35

Open barbmc opened 9 years ago

barbmc commented 9 years ago

Why does this conversion output 44 g?

var qtyunit = '3 tb'; qtyunit = Qty(qtyunit); qtyunit = qtyunit.to('ml').toPrec('ml').toString();

gentooboontoo commented 9 years ago

Could you check your example? I just tried and it outputted 44ml as expected:

Qty('3tbs').to('ml').toPrec('ml').toString(); // => "44 ml"

There's also a typo in your example: tb instead of tbs.

barbmc commented 9 years ago

There's 15mls in a tablespoon isn't there

Regards Barbara

Date: Thu, 19 Feb 2015 00:18:35 -0800 From: notifications@github.com To: js-quantities@noreply.github.com CC: barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

Could you check your example? I just tried and it outputted 44ml as expected:

Qty('3tbs').to('ml').toPrec('ml').toString(); // => "44 ml"

There's also a typo in your example: tb instead of tbs.

— Reply to this email directly or view it on GitHub.

gentooboontoo commented 9 years ago

According to several references, there's 14.7867648 ml in a tb (so approximately 44ml for three tb):

Qty('1 tbs').to('ml').toString(); // => "14.7867648 ml"
Qty('3 tbs').to('ml').toString(); // => "44.3602944 ml"

Do you have any issue when using it?

Whatever it be, I've added tb as tablespoon alias.

barbmc commented 9 years ago

Ok.

--- Original Message ---

From: "Julien Sanchez" notifications@github.com Sent: 19 February 2015 23:39 To: "gentooboontoo/js-quantities" js-quantities@noreply.github.com Cc: "barbmc" barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

According to several references, there's 14.7867648 ml in a tb (so approximately 44ml for three tb):

Qty('1 tbs').to('ml').toString(); // => "14.7867648 ml"
Qty('3 tbs').to('ml').toString(); // => "44.3602944 ml"

Do you have any issue when using it?

Whatever it be, I've added tb as tablespoon alias.


Reply to this email directly or view it on GitHub: https://github.com/gentooboontoo/js-quantities/issues/35#issuecomment-75045376

barbmc commented 9 years ago

Ok. How can I make it round up to 45 ml?

--- Original Message ---

From: "Julien Sanchez" notifications@github.com Sent: 19 February 2015 23:39 To: "gentooboontoo/js-quantities" js-quantities@noreply.github.com Cc: "barbmc" barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

According to several references, there's 14.7867648 ml in a tb (so approximately 44ml for three tb):

Qty('1 tbs').to('ml').toString(); // => "14.7867648 ml"
Qty('3 tbs').to('ml').toString(); // => "44.3602944 ml"

Do you have any issue when using it?

Whatever it be, I've added tb as tablespoon alias.


Reply to this email directly or view it on GitHub: https://github.com/gentooboontoo/js-quantities/issues/35#issuecomment-75045376

barbmc commented 9 years ago

Actually I added to myself which is why it was there :)

--- Original Message ---

From: "Julien Sanchez" notifications@github.com Sent: 19 February 2015 23:39 To: "gentooboontoo/js-quantities" js-quantities@noreply.github.com Cc: "barbmc" barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

According to several references, there's 14.7867648 ml in a tb (so approximately 44ml for three tb):

Qty('1 tbs').to('ml').toString(); // => "14.7867648 ml"
Qty('3 tbs').to('ml').toString(); // => "44.3602944 ml"

Do you have any issue when using it?

Whatever it be, I've added tb as tablespoon alias.


Reply to this email directly or view it on GitHub: https://github.com/gentooboontoo/js-quantities/issues/35#issuecomment-75045376

gentooboontoo commented 9 years ago

Currently, there's no way to redefine units. You could update the tablespoon value in your own fork here by replacing 1.47867648e-5 with 1.5e-5:

https://github.com/gentooboontoo/js-quantities/blob/master/src/quantities.js#L117

barbmc commented 9 years ago

Great thanks

--- Original Message ---

From: "Julien Sanchez" notifications@github.com Sent: 20 February 2015 00:03 To: "gentooboontoo/js-quantities" js-quantities@noreply.github.com Cc: "barbmc" barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

Currently, there's no way to redefine units. You could update the tablespoon value in your own fork here by replacing 1.47867648e-5 with 1.5e-5:

https://github.com/gentooboontoo/js-quantities/blob/master/src/quantities.js#L117


Reply to this email directly or view it on GitHub: https://github.com/gentooboontoo/js-quantities/issues/35#issuecomment-75048180

barbmc commented 9 years ago

I can give you lots of other aliases if you like.

--- Original Message ---

From: "Julien Sanchez" notifications@github.com Sent: 19 February 2015 23:39 To: "gentooboontoo/js-quantities" js-quantities@noreply.github.com Cc: "barbmc" barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

According to several references, there's 14.7867648 ml in a tb (so approximately 44ml for three tb):

Qty('1 tbs').to('ml').toString(); // => "14.7867648 ml"
Qty('3 tbs').to('ml').toString(); // => "44.3602944 ml"

Do you have any issue when using it?

Whatever it be, I've added tb as tablespoon alias.


Reply to this email directly or view it on GitHub: https://github.com/gentooboontoo/js-quantities/issues/35#issuecomment-75045376

gentooboontoo commented 9 years ago

Willingly. I could add any missing unit with actual use and not conflicting with existing ones.

barbmc commented 9 years ago

My complete list is attached. A lot of them won't be relevant to you as they come from recipes

Regards Barbara

Date: Thu, 19 Feb 2015 06:04:25 -0800 From: notifications@github.com To: js-quantities@noreply.github.com CC: barbara.mclennan@outlook.com Subject: Re: [js-quantities] Incorrect tablespoon conversion (#35)

Willingly. I could add any missing unit with actual use and not conflicting with existing ones.

— Reply to this email directly or view it on GitHub.