Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • CDMS
  • Castor CDMS Calculations Manual
  • General calculation templates

Force not to round a calculation result in EDC/CDMS

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • CDMS
    Castor CDMS Manual Castor CDMS Calculations Manual Frequently Asked Questions Articles for Data Managers Castor CDMS Compliance Release Documents
  • eConsent
    Castor eConsent Manual Castor eConsent Compliance Release Documents
  • SMS
    Castor SMS Manual Castor SMS Compliance Release Documents
  • Castor Connect
    Castor Connect Compliance Release Documents Castor Connect Manual Castor Connect - Participant Quick Start Guide
  • Helpdesk
    News Other Resources Castor products knowledge resources
  • Status page
  • Completing a Study
+ More

In Castor, a calculation used to perform mathematical operations applies rounding to two decimals by default. 


For example, we have two variables and we know that the result of adding them up should be 1392.43460062. We create our calculation in Castor:

var measure1 = {my_variable_1};
var measure2 = {my_variable_2};
measure1 + measure2;


The result of this calculation in Castor EDC will be 1392.43


To force to show all the decimal positions use the following code, where you replace {my_variable_1} and {my_variable_2} with your own variables:

'##allowempty##';
'##setemptytozero##';
var myNum = {my_variable_1} + {my_variable_2};
function countPlaces(myNum) {
 var text = myNum.toString();
 var index = text.indexOf(".");
 return index == -1 ? 0 : (text.length - index - 1);
}
myNum.toPrecision(countPlaces(myNum))


The result of this calculation will be 1392.43460062 instead of 1392.43

How does it work?

First, we declare our sum variable. Then we create a function that:

  1. converts the result of the addition to string
  2. counts the characters after the point (decimals)
  3. finally, with myNum.toPrecision(countPlaces(myNum)) we are forcing the result of myNum to be shown with as many decimals as specified within the parentheses. In this case, this will be our variable for the length captured in the previous step.
prevent rounding preserve precision

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Check if a number contains X number of digits or decimal places in EDC/CDMS
  • Check if all fields are filled in with in EDC/CDMS
ISO 27001
FDA - 21 CFR part 11
ICH GCP compliant
HIPAA compliant
CDISC
ISO 9001
gdpr compliant

Products & Industries

  • Electronic Data Capture (EDC)
  • ePRO
  • eConsent
  • Decentralized Clinical Trials (DCT)
  • Clinical Data Management
  • Medical Device & Diagnostics
  • Biotech & Pharma
  • CROs
  • Academic Research

Resources

  • Thought Leadership
  • Blog
  • Castor Academy
  • Knowledge Base

 

Company

  • About Us
  • Careers
  • News
  • Contact Support
  • Contact Us

Legal & Compliance

  • Terms of Use
  • Privacy & Cookie Statement
  • Responsible Disclosure Policy
  • Good Clinical Practice (GCP)
  • ISO Compliance Certificates
  • GDPR & HIPAA Compliance
  • Security Statement

© 2022, Castor. All Rights Reserved.

Follow us on social media


Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand