Home > Community > Forums > Custom IC SKILL > Converting float number to integer

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Converting float number to integer 

Last post Wed, Aug 12 2009 5:29 PM by kbhow. 4 replies.
Started by Vignesh054 12 Aug 2009 02:47 AM. Topic has 4 replies and 1697 views
Page 1 of 1 (5 items)
Sort Posts:
  • Wed, Aug 12 2009 2:47 AM

    • Vignesh054
    • Top 500 Contributor
    • Joined on Fri, Sep 26 2008
    • Hyderabad, Andhra Pradesh
    • Posts 20
    • Points 515
    Converting float number to integer Reply

    Hi,

    I have a variable and after calculation it is in the float format. But i want that in integer format. 

    Eg: i did a=10/3 ; a=3.33

    I want to change now the a to 3.

    Is this possible?

    Please help me.

    Thanks,

    Vignesh T K 

    • Post Points: 35
  • Wed, Aug 12 2009 2:53 AM

    • kbhow
    • Top 50 Contributor
    • Joined on Thu, May 7 2009
    • Penang, Pulau Pinang
    • Posts 120
    • Points 2,045
    Re: Converting float number to integer Reply

    Hi Vignesh,

     Try round(float_number)

     

    Regards, How

    • Post Points: 20
  • Wed, Aug 12 2009 3:04 AM

    Re: Converting float number to integer Reply
    Or floor(). It depends on how you want to do the rounding. There's also ceiling() if you want to round up.

    Regards,

    Andrew
    • Post Points: 5
  • Wed, Aug 12 2009 3:06 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,567
    • Points 15,575
    Re: Converting float number to integer Reply
    Hi Vignesh,

    Also the fix() function can be used to truncate the fraction
    part. Be aware that fix(3.51) will return 3 but round(3.51)
    will return 4.

    Regards,
    Lawrence.
    • Post Points: 20
  • Wed, Aug 12 2009 5:29 PM

    • kbhow
    • Top 50 Contributor
    • Joined on Thu, May 7 2009
    • Penang, Pulau Pinang
    • Posts 120
    • Points 2,045
    Re: Converting float number to integer Reply

    Hi Lawrence,

     I didn't notice that fix() will works on this condition. Cool, i really learn a lot from you and andrew.

     Regards, How

    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by Vignesh054 at 12 Aug 2009 02:47 AM. Topic has 4 replies.