• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 60
  • Last Modified:

logarithm in rpgle

How a calculate  log base2 (X) (any value to log base 2 )  in rpgle ?
0
kishore murarisetty
Asked:
kishore murarisetty
1 Solution
 
Gary PattersonVP Technology / Senior Consultant Commented:
You can call the log2 ILE CEE APIs: CEESSLG2 (single precision floating point value) or CEESDLG2 (double precision floating point)

See page 92 of the ILE CEE API Reference:  ftp://ftp.software.ibm.com/systems/power/docs/systemi/v5r4/en_US/ile.pdf

Untested, but should give you the basic idea.

ctl-Opt actgrp('TEST') option(*srcStmt: *noDebugIO);

dcl-Pr log2 extProc('CEESDLG2');
  input    float(8) const;
  output float(8);
  error    char(12) options(*omit);
end-Pr;

dcl-S x float(8) ;
dcl-S result float(8) ;

// Mainline
x = 8 ;
log2(x : result : *OMIT);
return;

Open in new window

1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now