Find Whether Given Number is Power of 2 or Not

*& Program name                :  Z1
*& Author                      : BASAVARAJ
*& Create date                : 15/09/2006
*& Program type                :  SIMPLE PROGRAM
*& SAP release                :  4.6C
*& DESCRIPTION                :    FIND WHETHER GIVEN NUMBER IS POWER OF 2
*                                        OR NOT
************************************************************************

REPORT Z1 .

parameters: num type i.

data: var type i value 2.

while num > var .

    multiply var by 2.

endwhile.

if var eq num.

    write:/' given no s poer of 2'.

else.

write:/ 'no s not power of 2'.

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP ERP Modules, Basis, ABAP and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.