Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Binay Calculation

Hello all,

I have value in Database Type i For example 96

I want to find out the binary Value.

Example :

That 2 4 8 16 32 64 = 96

Has somebody an Idear ??

I that possible in ABAB. in java thas only a few line

regards

Chris

Tags:
Former Member
replied

Ich habe das Programm für dich modifiziert, finde aber seltsam, dass du allein nicht machen konntest...

DATA:
  base TYPE i,
  dividend TYPE i,
  binary TYPE string,
  tmp(3) TYPE c,
  tmp2(3) TYPE c,
  q TYPE i.

q = 96.
MOVE q TO tmp2.
base = 128.
tmp = base.
DO 8 TIMES.
  dividend = q DIV base.
  IF dividend > 0.
    CONCATENATE binary '+' tmp INTO binary SEPARATED BY space.
    q = q - base.
  ENDIF.

  base = base / 2.
  tmp = base.
ENDDO.

SHIFT binary LEFT DELETING LEADING '+ '.
CONCATENATE tmp2 '=' binary INTO binary SEPARATED BY space.

WRITE:/ binary.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question