Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kasper Dyrvig 246 posts 379 karma points
    Oct 29, 2010 @ 11:34
    Kasper Dyrvig
    0

    Doing math with xslt

    I have set up this formel: (y * 1000) / 3600 = x

      <xsl:template name="dws">
        <xsl:param name="windspeed"/>
        <xsl:value-of select="($windspeed * 1000) div 3600"/>
      </xsl:template>

    It works perfect! A little too perfect... One of the results are "5.277777777777778". I would like to be just "5". Any one who knows how to do that?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Oct 29, 2010 @ 11:46
    Chriztian Steinmeier
    1

    Hi Webspas,

    You can use floor() to round down to nearest integer, and ceiling() to round up: 

    <xsl:value-of select="floor(($windspeed * 1000) div 3600)"/> 

    /Chriztian

  • Kasper Dyrvig 246 posts 379 karma points
    Oct 29, 2010 @ 12:20
    Kasper Dyrvig
    0

    Cool! Thanks (again) Chriztian!

Please Sign in or register to post replies

Write your reply to:

Draft