How can I get INTeger from float

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randell D.

    How can I get INTeger from float


    Folks,

    If I have a number that includes decimal points and I want to remove
    everything right of the decimal, how do I do it - I know I could explode
    using the point as a delimiter but that doesn't look legal.

    I've tried

    $t=1.532;
    $y=int($t);


    but that didn't work out for me...

    any ideas?

    thanks
    randelld


  • Dana

    #2
    Re: How can I get INTeger from float

    Randell D. wrote:[color=blue]
    > If I have a number that includes decimal points and I want to remove
    > everything right of the decimal, how do I do it[/color]

    floor()

    Comment

    • Randell D.

      #3
      Re: How can I get INTeger from float


      "Dana" <Dana@nospamnex lab.it> wrote in message
      news:bijlfr$f5i $1@newsreader.m ailgate.org...[color=blue]
      > Randell D. wrote:[color=green]
      > > If I have a number that includes decimal points and I want to remove
      > > everything right of the decimal, how do I do it[/color]
      >
      > floor()[/color]

      Many thanks - I never heard of the function before nor would I have ever
      guessed it.

      Cheers.


      Comment

      • nylz

        #4
        Re: How can I get INTeger from float

        Randell D. wrote:[color=blue]
        > "Dana" <Dana@nospamnex lab.it> wrote in message
        > news:bijlfr$f5i $1@newsreader.m ailgate.org...
        >[color=green]
        >>Randell D. wrote:
        >>[color=darkred]
        >>>If I have a number that includes decimal points and I want to remove
        >>>everything right of the decimal, how do I do it[/color]
        >>
        >>floor()[/color]
        >
        >
        > Many thanks - I never heard of the function before nor would I have ever
        > guessed it.
        >
        > Cheers.
        >
        >[/color]

        you were close yourself anyway:

        $t=1.532;
        $y=(int)$t;

        should work too

        Comment

        Working...