I have a idea that I am doing and it is working so far but when it
comes to displaying the data that I am getting
with the maths that I am doing I am not getting the same result.
I am 100% sure the maths is working as I firstly did it on paper and
took those steps and put them into the action.
When it comes to the display I am superpose to get 2.75 but I only see
2 why is that
by default if you are working with integers you'll always get integers
back (by truncation). If you want floating point numbers then you
should convert the numbers you're working with to floating point
numbers first (using to_f), so
5 /2 will always return 2, but 5.0 / 2 will produce 2.5
I have looked at number_with_precision but rather then getting 2.75 I
get 2.00
number_with_precision is for formatting a number, you still need to
actually have a number with the floating point component.
Without the code used in the display action it's difficult to know
what's going on but I'd guess you're using an integer at some point
and that causes loss of precision.
by default if you are working with integers you'll always get integers
back (by truncation). If you want floating point numbers then you
should convert the numbers you're working with to floating point
numbers first (using to_f), so
5 /2 will always return 2, but 5.0 / 2 will produce 2.5