Announcement

Collapse
No announcement yet.

Integer Conversion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integer Conversion

    So far this forum has been unbelievably helpful, so here goes another question:

    How does one define an integer variable, or convert a floating point number to the nearest integer value (i.e. rounded not truncated)?

    I'm trying to divide two numbers and use the result as a counter variable, but there is floating point error in the result (which should be a whole number). I could only find the parseInt() function, but that's only for string conversion, right? I know this is real basic stuff, but my last programming language was FORTRAN (it's okay, go ahead and laugh).

    Thanks.
    pa-kay

  • #2
    Math.round(x) wil round x to the nearest integer, according to my java script book.

    Comment


    • #3
      Hello pa-kay,

      Here's a couple of links to some JavaScript 1.5 resources you'll find useful. These are also mentioned in the EFS Help Center & Library at the bottom link.

      Core JavaScript Guide 1.5
      Core JavaScript Reference 1.5
      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment


      • #4
        Thank you. I'll make better use of the reference links in the future. Sure enough, there is an example in the EFS Help Center & Library showing how to round a number. Long ago it was necessary to define a variable as an integer, floating point, or string type. Of course, that seems pretty stodgy now, kinda like how my brain is working lately.

        Fantastic! Thank you again.
        pa-kay

        Comment

        Working...
        X