1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use <xen:calc ''> = an integer

Discussion in 'XenForo Development Discussions' started by starvnnet, Nov 11, 2013.

  1. starvnnet

    starvnnet Member

    I'm editing my template and i use <xen:calc '5/2'>
    Value => 2.5 (float number)
    Now i want an integer. It mean 5/2 = 2.

    Can you help me ?
    vfustar likes this.
  2. cclaerhout

    cclaerhout Well-Known Member

    {xen:calc "round(5 / 2)"}
    Output: 3
    {xen:calc "floor(5 / 2)"}
    Output: 2
    {xen:calc "ceil(5 / 2)"}
    Output: 3

    Other functions compatible with the calc helper: abs, max, min, pow.

    Check php manual to see what is the effect of these functions. You can also check inside XenForo templates. There are some.
    bousaid and starvnnet like this.
  3. starvnnet

    starvnnet Member

    Thank you so much (y)
  4. jayramfootball

    jayramfootball Active Member

    Is there some documentation for the different xen:calc functions like 'floor', 'round'. 'ceiling' ? Could someone point me to it... having a hard time finding anything even with some good searches...
    Sean Kendle likes this.
  5. Nobita.Kun

    Nobita.Kun Well-Known Member

    'floor', round', ceil' is PHP functions. You can read that on document!
    jayramfootball likes this.
  6. jayramfootball

    jayramfootball Active Member

    Does that mean any php functions will work with Xen:calc ?
    Sean Kendle likes this.
  7. Nobita.Kun

    Nobita.Kun Well-Known Member

    Dont tested but its should work. And as post above given example ;)

Share This Page