Stone & Pounds minus Stone & Pounds

Stone & Pounds minus Stone & Pounds

Hello everyone,

I've made a formula to calculate the difference between two decimal fields for example:

12.13 = 12 stones and 13 pounds

Now I would like to calculate the difference between two stone & pounds decimal fields. The script I've written is below.

The problem is 0.14 pounds is 1 stone. So in the below formula I got a problem with the following outcome:
1.15. Actually this has to be 2 stone and 0,01 pounds.

How could I resolve this?
//Calculatie today's weight loss in stones and lbs
//Stones&LBS to stones Current Weight
Stones_CW = (row.Current_Weight.toLong()  *  13.5);
LBS_CW = ((row.Current_Weight  -  row.Current_Weight.toLong())  *  100);
CW = (Stones_CW  +  LBS_CW);
//Stones&LBS to stones Today's Weight
Stones_TW = (row.Today_s_Weight_st_lbs.toLong()  *  13.5);
LBS_TW = ((row.Today_s_Weight_st_lbs  -  row.Today_s_Weight_st_lbs.toLong())  *  100);
TW = (Stones_TW  +  LBS_TW);
//Calculate difference between CW and TW
Difference = ((TW  -  CW)  /  13.5);
Stones_DF = Difference.toLong();
LBS_DF = ((Difference  -  Stones_DF)  *  0.135);
row.Weight_Loss_Today = (Stones_DF  +  LBS_DF);
//Calculatie total weight loss in stones and lbs
//Stones&LBS to stones Starting Weight
X  =  Members  [ID = row.Select_member];
Stones_SW = (X.Starting_Weight_st_lbs.toLong()  *  13.5);
LBS_SW = ((X.Starting_Weight_st_lbs  -  X.Starting_Weight_st_lbs.toLong())  *  100);
SW = (Stones_SW  +  LBS_SW);
//Stones&LBS to stones Today's Weight
Stones_TW1 = (row.Today_s_Weight_st_lbs.toLong()  *  13.5);
LBS_TW1 = ((row.Today_s_Weight_st_lbs  -  row.Today_s_Weight_st_lbs.toLong())  *  100);
TW1 = (Stones_TW1  +  LBS_TW1);
//Calculate difference between CW and TW
Difference1 = ((TW1  -  SW)  /  13.5);
Stones_DF1 = Difference1.toLong();
LBS_DF1 = ((Difference1  -  Stones_DF1)  *  0.135);
row.Total_Weight_Loss = (Stones_DF1  +  LBS_DF1);

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now