Results 1 to 4 of 4

Thread: Please Help!!!!

  1. #1

    Thread Starter
    Member Evil_Ryu's Avatar
    Join Date
    Mar 2001
    Location
    In the Shotokan Dojo...
    Posts
    58

    Unhappy Please Help!!!!

    I need a function that take away the decimal from a number... a function that do this...

    the number:

    12,34555555


    the result:

    12,3

    Can i do this with a javascript function or i have to do it by myself??


    Any idea would be useful... thanks...

  2. #2
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    Ack number one this is a java forum, not a javascript forum, number two I believe that you miswrote you example. If you want a function to take away the decimal, how do you go from 12.3455555 to 12.3 Do you want significant digits or do you want to convert a float to an int?

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Do you mean 12,34555555 as 12.34555555? I think that is what you ment. Yes as billrogers pointed out you would be better asking this in the java script forum. If you were doing this in java then you could cast the double value to an int to lose the precision.
    Code:
     class decimal{
        public static void main(String[] args){
          double d = 34.42; 
          int i = (int)d;
          System.out.println(d);  
          System.out.println(i);  
       }
      }

  4. #4
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    Yep that would work, I didnt know if he wanted to round just at the decimal though or to a specified significant digit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width