Results 1 to 14 of 14

Thread: How to determine Length of number

  1. #1
    Guest

    Talking

    ihave a number "hallo", or 0.00568 how can i determine the length of it?

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Code:
    Private Sub Command1_Click()
        MsgBox "Length is " & Len(Str(0.00568))
    End Sub
    Is this what you are looking for ?

  3. #3
    Guest

    Talking

    Ya ya ... that's it... thanks
    and by the way, do you know how can we find the location of a number in a series of number
    0.0000005
    where is the location of 5? it is not aways 5 not i try to dormat the number to 5 * 10^ n somthing like that, so i need to figure out the first number after decimal and 0
    once again, tghanks

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You could temporarily convert it to a string and then use the len() function. Will that accomplish what you want?

    Code:
      It looks like someone just posted code for you as I was writing this
    As for the second thing:

    Just split(OrigNumber,".") after converting it to a string and then work with mysplit(1) in the rest of the code, that will be only what is after the decimal

    [Edited by Edneeis on 10-12-2000 at 02:23 PM]

  5. #5
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Similar to this ?

    Code:
    Private Sub Command2_Click()
        Dim NumToSearch As Double
        Dim NumToLocate As Integer
        
        NumToSearch = 0.0005
        NumToLocate = 5
        
        MsgBox InStr(1, NumToSearch, NumToLocate)
    End Sub

  6. #6
    Guest
    I think it will not work as it is not always 5 and how about this one?
    Y2 = 0.01
    Do While Y2 < 1
    z = z + 1
    Y2 = Y2 * 10
    Loop
    Text2.Text = Y2

    why i can not get y2 as 1 .. but 9.99999999

    anyone help here

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    the logaritmical solution
    Code:
    msgbox -int(log(0.00005)/2.30258509299405)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Guest

    Talking

    Guru , are you kidding me or what?
    i try the example i posted... it doesn't give me 1 but give me 9.999999999999999999999 wonder why, help please

  9. #9
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    dragonyian,
    this page will explain you why you get these strange errors:
    (Complete) Tutorial to Understand IEEE Floating-Point Errors

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    eh sorry divide with a bit smaller number or to be really sure log(10)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11
    Guest

    Talking

    So, what do you guys think i can do...
    what i need is to loop and figure out how small the number is and then make it as 5 *10^6 something like that... any suggestion?

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Why don't you go try the ten'th logaritm?
    Code:
    msgbox -int(log(0.00005)/log(10))
    should work now, i've tested it out
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13
    Lively Member flint's Avatar
    Join Date
    Oct 2000
    Posts
    67
    Dragonyian: I posted this reply in the center form thread as well.

    The
    Code:
    do while y <1
    does not allow the Y varible to become 1. Your code continues to multiply Y(0.01) * 10 until the value of Y = .99

    take .99 * 10 and you get 9.99

    hope this helps

    Flint

    A man will pay $2 for a $1 item he wants. A woman will pay $1 for a $2 item that she doesn't want.

  14. #14
    Lively Member flint's Avatar
    Join Date
    Oct 2000
    Posts
    67

    Thumbs down

    Did this help Dragonyian?

    Flint

    Eating words has never given me indigestion.
    — Winston Churchill: 1874-1965, British
    politician, writer

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