• Resolved pureswing

    (@pureswing)


    Hello!

    I’m trying to get rid of a decimal point without rounding, already tried floor(), ceil(), prec(), ToFixed() without luck.I find out that trunc() do the trick in Javascript, but I don’t know how to implement it in the equation.

    This does not work:

    (function(){
    
    var result = trunc(fieldname2/fieldname4);
    jQuery('.equation-result').html(result);
    return result;
    
    })();

    THx for your huge support to this plugins!!

    • This topic was modified 7 years, 4 months ago by pureswing.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @pureswing,

    The equation’s code would be:

    (function(){
    var result = IF(fieldname4, FLOOR(fieldname2/fieldname4), '');
    jQuery('.equation-result').html(result);
    return result;
    })();

    Please, remember that javascript os case sensitive language.

    If the issue persists, please, send me the link to your webpage for checking it in detail.

    Best regards.

    Thread Starter pureswing

    (@pureswing)

    great, it works, that was fast ?? THX !!! ..by the way I found another small problem with a simple division in another field:

    fieldname22 = 230
    fieldname26 = 7
    CF = 233 / 7 = 32.8571428…..
    Using prec():
    prec(fieldname22/fieldname26,2) = 32.86 which it’s not good, that field has to be consistent with 2 decimals without rounding, in other words I need a 32.85. Any solution around this??

    Sorry for bothering you again my friend..
    Regards

    Plugin Author codepeople

    (@codepeople)

    Hello @pureswing,

    PREC(X,Y) “rounds” the X number with Y decimal places. If you want simply truncate the decimal places, the solution would be pure mathematics:

    FLOOR(n*100)/100

    For example, using your current equation:

    FLOOR(fieldname22/fieldname26*100)/100

    and replacing the values:

    FLOOR(230/7*100)/100 =
    FLOOR(32.857142857142854*100)/100 =
    FLOOR(3285.7142857142854)/100 =
    3285/100 = 32.85

    I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas). If you need additional support implementing your project, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘eliminating decimal point without rounding’ is closed to new replies.