Home » JavaScript Tutorial

Math.clz32() Method with Example in JavaScript

JavaScript | Math.clz32() Method: Here, we are going to learn about the clz32() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on December 25, 2019

JavaScript | Math.clz32() Method

Math.clz32() is a function in math library of JavaScript that is used to find the number of leading zeroes in the 32-bit representation of the number. The method will return the numeric value which is the number of leading zeroes.

Syntax:

    Math.clz32(x);

Parameter(s):

  • x – represents a value whose number of leading zero bit in the 32-bit representation to be returned.

Return value:

The return type of this method is number, it returns the number of leading zero bit in the 32-bit representation of the number.

Technical Insights:

  • JavaScript version: ECMAScript 1
  • Browser support: Chrome, Internet Explorer, Mozilla, Safari, Opera mini

Values accepted: Integer, floating-point, numeric string.

Invalid Values: empty variable, empty array all will return NaN (Not a Number).

Example 1: Valid values for the method

console.log(Math.clz32(2));
console.log(Math.clz32(10.98));
console.log(Math.clz32(-198.23));
console.log(Math.clz32(0));
console.log(Math.clz32("734.18"));

Output

30
28
0
32
22

Example 2: Invalid values for the method.

console.log(Math.clz32(1 + 5i));
// Output: Uncaught SyntaxError: Invalid or unexpected token






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.