Set round to 3 decimals? (Dawn 5)

Solved
Sneaky
Shopify Partner
32 3 18

I am trying to figure out how I can set a variable in my theme.liquid file to 3 decimals, it currently reverts to 2 decimals.  So for example I may have a result calculation that should be 1.875 but it rounds to 1.87

 

I have tried to divide by a 3 decimal number, e.g. 100.000, or 1.000, or 2.000 etc

I have tried to set round to 3

I have tried to set abs

 

Nothing is working so far, it always reverts to 2 decimals.

 

Any suggestions?

Accepted Solution (1)
Sneaky
Shopify Partner
32 3 18

This is an accepted solution.

OK, I am not sure why but I was able to fix it by switching the order of my divide_by in the calculation.

Example

 

{{ settings.font_number_size | times: settings.font_default_scale | divided_by: settings.font_body_size | divided_by: 100.000 | round: 3 }}

 

 

To

 

{{ settings.font_number_size | times: settings.font_default_scale | divided_by: 100.000 | divided_by: settings.font_body_size | round: 3 }}

 

Well, it resolves my specific issue

 

I looked at this again and to be easier just adding a times or divide_by as 1.000 fixes it too.

For example

 

{{ settings.font_number_size | times: settings.font_default_scale| times: 1.000 | divided_by: settings.font_body_size | divided_by: 100 | round: 3 }}

 

View solution in original post

Replies 3 (3)
Sneaky
Shopify Partner
32 3 18

This is an accepted solution.

OK, I am not sure why but I was able to fix it by switching the order of my divide_by in the calculation.

Example

 

{{ settings.font_number_size | times: settings.font_default_scale | divided_by: settings.font_body_size | divided_by: 100.000 | round: 3 }}

 

 

To

 

{{ settings.font_number_size | times: settings.font_default_scale | divided_by: 100.000 | divided_by: settings.font_body_size | round: 3 }}

 

Well, it resolves my specific issue

 

I looked at this again and to be easier just adding a times or divide_by as 1.000 fixes it too.

For example

 

{{ settings.font_number_size | times: settings.font_default_scale| times: 1.000 | divided_by: settings.font_body_size | divided_by: 100 | round: 3 }}

 

afcompany
Shopify Partner
12 0 5

Where do you make this change? I am trying to get my cart to display .000 or .0000 (3 or 4) decimal places.

wesstraub
New Member
4 0 0

Where / what file are you making this modification to?