{"id":24196,"date":"2021-10-14T09:17:58","date_gmt":"2021-10-14T03:47:58","guid":{"rendered":"https:\/\/python-programs.com\/?p=24196"},"modified":"2021-11-05T20:55:53","modified_gmt":"2021-11-05T15:25:53","slug":"python-program-for-ldexp-function","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-ldexp-function\/","title":{"rendered":"Python Program for ldexp() Function"},"content":{"rendered":"

In the previous article, we have discussed Python Program for isnan() Function<\/a>
\nldexp() Function in Python:<\/strong><\/p>\n

The inverse of math.frexp() is returned by the math.ldexp() method, which returns x * (2**i)<\/strong> of the given numbers x and i. ().<\/p>\n

For example:<\/p>\n

Let x= 3, i=4<\/p>\n

Then math.ldexp(x, i) = 3*(2**4) = 48<\/p>\n

Syntax:<\/strong><\/p>\n

math.ldexp(x, i)<\/pre>\n

Parameters:<\/strong><\/p>\n

x: This is required. A number that is either positive or negative. It returns TypeError if the value is not a number.<\/p>\n

i: This is required. A number that is either positive or negative. It returns TypeError if the value is not a number.<\/p>\n

Return value: <\/strong>It returns the value of x * (2**i)<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given x value = 3\r\nGiven i value = 4<\/pre>\n

Output:<\/strong><\/p>\n

The value of given  x * (2**i) = 48.0<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given x value = 5\r\nGiven i value =  6<\/pre>\n

Output:<\/strong><\/p>\n

The value of given x * (2**i) = 320.0<\/pre>\n

Program for ldexp() Function in Python<\/h2>\n