numbers investigation

  • Thread starter Thread starter andreas
  • Start date Start date
A

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
 
andreas said:
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...'.
 
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
 
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..
 
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
 
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
 
Back
Top