prakasam k
prakasam k

Reputation: 89

How to check whole number in vc++?

UINT itemLength = strValue.length();
        bRet = ( ( itemLength > maxLength ) || ( itemLength < minLength ) ) ? VARIANT_FALSE : VARIANT_TRUE;

This code is being used for Length validation.

I want to validate number:

For Ex:

min value = 0, Max value =10, original value = 5

In this condition i want to check only whole number.

For Ex, I want to display following:

Input -> Output

5 -> True

5.1 -> False i want to display.

Upvotes: 2

Views: 441

Answers (1)

Chris Derry
Chris Derry

Reputation: 41

assuming f as precision number try this

if (f % (int)f > 0)
    {
        Console.WriteLine("is not whole number");
    }
    else
    {
        Console.WriteLine("is whole number");
    }

Upvotes: 1

Related Questions