Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How to check if an integer is even or odd?

(0) ShareShare
ReportReport
Posted on by 422

Hi, is there any way to check if an integer is even or odd?

*This post is locked for comments

  • AbduTeeyech Profile Picture
    AbduTeeyech 422 on at
    RE: How to check if an integer is even or odd?

    Hi Youssef, thank you.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check if an integer is even or odd?

    If ( #yournumber MOD 2) = 0 then

     Message('even')

    Else

     Message('odd');

  • AbduTeeyech Profile Picture
    AbduTeeyech 422 on at
    RE: How to check if an integer is even or odd?

    [int] mod 2 ==1 ??

  • Verified answer
    Luc van Vugt Profile Picture
    Luc van Vugt on at
    RE: How to check if an integer is even or odd?

    Use the MOD operator.

    X MOD 2 will result in 0 or 1, when X is respectively even or odd.

    Funny is that the MOD operator is not (well) documented. But read some about it here www.mibuso.com/.../viewtopic.php

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check if an integer is even or odd?

    If ( [tag:yournumber] MOD 2) = 0 then

      Message('even')

    Else

      Message('odd');

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to check if an integer is even or odd?

    Hi, use the MOD 2 function to check if there's a remainder then it's odd if not it's even

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans