Results 1 to 4 of 4

Thread: Fix, round etc....

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Fix, round etc....

    Hi,

    Is there a function for cutting off a number at a specified number of decimals, rather than rounding it?

    If my number is:

    x = 12.6549

    How can I return it to only 2,3 or whatever specified number of decimal places, like 12.6?

    Fix(x) only returns the integer part.

    Thanks for any help!

  2. #2
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    just a suggestion - could you not use the format function

    ie

    Format(12.6549, "00.0")



    I think thats the right syntax
    ** HOLLY **

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281
    No format doesn't work. Still rounds it off

    eg:

    dim number as double
    number=4.568972

    picture1.print Format(number, "0.0")

    This will print 4.6, rather than 4.5

    Thanks anyway.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    in that case... where "dp" is the number of decimal places:

    int(12.6549 * (10^ dp) ) / (10^ dp)

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