Home All Groups Group Topic Archive Search About

numbers investigation

Author
23 Jun 2006 4:53 PM
andreas
Hi,
I have to investigate many decimal numbers if they are integral or not and I
know that max =99999,999..
What I do is :

str = cStr(numbD)
If str.length <= 5 then ...

I wonder if this is the fasted method to do so
Thanks for any responsE

Author
23 Jun 2006 5:06 PM
Herfried K. Wagner [MVP]
"andreas" <andr***@pandora.be> schrieb:
> I have to investigate many decimal numbers if they are integral or not and
> I
> know that max =99999,999..
> What I do is :
>
> str = cStr(numbD)
> If str.length <= 5 then ...
>
> I wonder if this is the fasted method to do so

'If numbD <= 99999,999 Then...'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
23 Jun 2006 6:10 PM
andreas
No, Herfried maybe  I make myself not clear anough.
I want to check out if the number is f.e. 89457 and not 89457,14578245781


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:eaPyQdulGHA.2136@TK2MSFTNGP04.phx.gbl...
> "andreas" <andr***@pandora.be> schrieb:
> > I have to investigate many decimal numbers if they are integral or not
and
> > I
> > know that max =99999,999..
> > What I do is :
> >
> > str = cStr(numbD)
> > If str.length <= 5 then ...
> >
> > I wonder if this is the fasted method to do so
>
> 'If numbD <= 99999,999 Then...'.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
Author
24 Jun 2006 12:12 AM
Cyril Gupta
I am sorry, but I can't see how this code helps. This will merely tell you
whether the number is less than 5 characters long... mm.. How does it help
you find that the number has no fractions?

Maybe you can simply use this

if mynum = int(mynum) then
my number is integral

hmm.. i hope i didn't understand what you wanted to do..
Author
24 Jun 2006 5:12 AM
andreas
Yes, I think that the code helps
f.e. I want to know of NumberD^0.3 is integral
This is true as cstr(NUmberD^0.3).lenght <= 5 (I know that NumberD
<=99999,999999999)
Don't you agree?
Thanks for your answer


Show quoteHide quote
"Cyril Gupta" <nomail@nospam.com> wrote in message
news:u6m1oLylGHA.2180@TK2MSFTNGP05.phx.gbl...
> I am sorry, but I can't see how this code helps. This will merely tell you
> whether the number is less than 5 characters long... mm.. How does it help
> you find that the number has no fractions?
>
> Maybe you can simply use this
>
> if mynum = int(mynum) then
> my number is integral
>
> hmm.. i hope i didn't understand what you wanted to do..
>
>
>
Author
25 Jun 2006 11:41 AM
Stephany Young
But ....

  (CStr(123.4).Length <= 5) = True

but 123.45 is not integral.

Also, if you use (_num = Int(_num)) then you will run into rounding issues
on various numeric values.

In my opinion it is best to use the Fix method:

  If Fix(_num) = _num Then
    ' _num is integral
    If _num <= 99999 Then
      ' _num is in range
    End If
  End If

or

  If Fix(_num) = _num AndAlso _num <= 99999 Then
    ' _num is integral and it is in range
  End If


Show quoteHide quote
"andreas" <andr***@pandora.be> wrote in message
news:dR3ng.499679$_d7.12684343@phobos.telenet-ops.be...
> Yes, I think that the code helps
> f.e. I want to know of NumberD^0.3 is integral
> This is true as cstr(NUmberD^0.3).lenght <= 5 (I know that NumberD
> <=99999,999999999)
> Don't you agree?
> Thanks for your answer
>
>
> "Cyril Gupta" <nomail@nospam.com> wrote in message
> news:u6m1oLylGHA.2180@TK2MSFTNGP05.phx.gbl...
>> I am sorry, but I can't see how this code helps. This will merely tell
>> you
>> whether the number is less than 5 characters long... mm.. How does it
>> help
>> you find that the number has no fractions?
>>
>> Maybe you can simply use this
>>
>> if mynum = int(mynum) then
>> my number is integral
>>
>> hmm.. i hope i didn't understand what you wanted to do..
>>
>>
>>
>
>