Converting the total amount of decimals

Report a typo

Johnny Joestar needs to create a small Go program that can take as input within the mathConstant variable different float64 values, such as the Golden ratio, Pi, and Euler's number. Then the program converts the input value to a string without losing any decimal points, and finally, prints the result.

Please help Johnny use the strconv.FormatFloat() function with the correct arguments to convert all the decimals of the mathConstant variable to a string and print the result to the console.

Sample Input 1:

1.618033988749894

Sample Output 1:

1.618033988749894
Write a program in Go
package main

import (
"fmt"
"strconv"
)

const FloatPrecision = 64

func main() {
// Do not change or delete these two lines below!
var mathConstant float64
fmt.Scanln(&mathConstant)

// Write in the '?' the missing arguments required to properly convert
// all the decimals of the 'mathConstant' variable to a string!
val := strconv.FormatFloat(?, '?', ?, FloatPrecision)

// This line prints the converted value, do not delete it!
fmt.Printf("%s", val)
}
___

Create a free account to access the full topic