Nottoobright
Technical User
I have an expenses form which usually adds up correctly, however when I put in the following figures it adds up with this reacurring number. Why?
The figures are:
4.50
2.95
6.80
7.70
2.40
and it adds them up to be:
24.349999999999998
instead of 24.35
The code is this:
var sub = 0;
if (T1.value > 0){
sub=sub + eval(T1.value)};
if (T2.value > 0){
sub=sub + eval(T2.value)};
if (T3.value > 0){
sub=sub + eval(T3.value)};
if (T4.value > 0){
sub=sub + eval(T4.value)};
if (T5.value > 0){
sub=sub + eval(T5.value)};
if (T6.value > 0){
sub=sub + eval(T6.value)};
if (T7.value > 0){
sub=sub + eval(T7.value)};
if (T8.value > 0){
sub=sub + eval(T8.value)};
if (T9.value > 0){
sub=sub + eval(T9.value)};
if (T10.value > 0){
sub=sub + eval(T10.value)};
if (T11.value > 0){
sub=sub + eval(T11.value)};
total.value= sub;
Thanks
The figures are:
4.50
2.95
6.80
7.70
2.40
and it adds them up to be:
24.349999999999998
instead of 24.35
The code is this:
var sub = 0;
if (T1.value > 0){
sub=sub + eval(T1.value)};
if (T2.value > 0){
sub=sub + eval(T2.value)};
if (T3.value > 0){
sub=sub + eval(T3.value)};
if (T4.value > 0){
sub=sub + eval(T4.value)};
if (T5.value > 0){
sub=sub + eval(T5.value)};
if (T6.value > 0){
sub=sub + eval(T6.value)};
if (T7.value > 0){
sub=sub + eval(T7.value)};
if (T8.value > 0){
sub=sub + eval(T8.value)};
if (T9.value > 0){
sub=sub + eval(T9.value)};
if (T10.value > 0){
sub=sub + eval(T10.value)};
if (T11.value > 0){
sub=sub + eval(T11.value)};
total.value= sub;
Thanks