# bits.Mul64() Function in Golang with Examples

bits.Mul64() Function in Golang is used to find the 128-bit product of x and y. The execution time of this function does not depend on the inputs. To access this function, one needs to imports the math/bits package in the program.

Syntax:

`func Mul64(x, y uint64) (hi, lo uint64)`

Parameters: This function takes two parameter of uint64 type, i.e., x, y.

Note: (hi, lo) = x * y
Here, hi is the product bits’ upper half and, lo is the lower half returned.

Return Value: This function returns the 128-bit product of x and y.

Example 1:

 `// Golang program to illustrate  ` `// bits.Mul64() Function  ` `package main  ` `    `  `import (  ` `    ``"fmt"` `    ``"math/bits"` `)  ` `    `  `// Main function  ` `func main() {  ` `    `  `    ``// Using Mul64() function  ` `    ``hi, lo  := bits.Mul64(15, 25)  ` `    ``fmt.Println(``"128-bit product of x and y : "``, hi, lo)  ` `    `  `} `

Output:

```128-bit product of x and y :  0 375
```

Example 2:

 `// Golang program to illustrate  ` `// bits.Mul64() Function  ` `package main  ` `    `  `import (  ` `    ``"fmt"` `    ``"math/bits"` `)  ` `    `  `// Main function  ` `func main() {  ` `    `  `    ``// Using Mul64() function  ` `    ``const` `a, b = 10, 30 ` `    ``hi, lo  := bits.Mul64(a, b)  ` `    ``fmt.Println(``"Number 1:"``, a)  ` `    ``fmt.Println(``"Number 2:"``, b)  ` `    ``fmt.Println(``"Upper half:"``, hi)  ` `    ``fmt.Println(``"Lower half:"``, lo)   ` `    `  `} `

Output:

```Number 1: 10
Number 2: 30
Upper half: 0
Lower half: 300
```

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Previous
Next