Converting special float strings

Report a typo

Emma really likes special floating numbers in Go, such as NaN, -0 and +Inf. She wants to create a Go program that can take these special floating numbers as a string input within the stringNum variable, then convert it to a float64 type, and print the converted type and the value to the console.

Emma wrote part of the code required to create her program, but it is still missing some very important parts. Please help Emma write the missing code required to make her program work.

Sample Input 1:

+Inf

Sample Output 1:

float64 +Inf
Write a program in Go
package main

import (
"fmt"
"log"
"strconv"
)

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

// Write in the '?' below the missing code to complete the program
?, err := strconv.?(?, ?)
if err != nil {
log.Fatal(err)
}

// Please add the missing code to print the converted type and its value below:
fmt.Printf("%T %v", ?, ?)
}
___

Create a free account to access the full topic