Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,945 questions

51,886 answers

573 users

How to construct a 64-bit floating-point value from the mantissa m, exponent e, and sign flag s in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"math"
)

func Construct64bitFloatingPointValue(m float64, e int, s bool) float64 {
	sign := 1.0
    if s {
        sign = -1.0
    }

    return sign * m * math.Pow(10, float64(e))
}

func main() {
    // Mantissa — the core number to be scaled.
    m := 5.1   // float64
    // exponent
    e := 10    // int
    // Sign flag: false means positive.
    s := false // bool

    fmt.Printf("%.0f\n", Construct64bitFloatingPointValue(m, e, s)) 
}



/*
run:

51000000000

*/

 



answered Jul 14, 2025 by avibootz
edited Jul 14, 2025 by avibootz
...