tempconv

package
v0.0.0-...-f53f79a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package tempconv performs Celsius and Fahrenheit temperature computations.

Example (One)
{
	//!+arith
	fmt.Printf("%g\n", BoilingC-FreezingC) // "100" °C
	boilingF := CToF(BoilingC)
	fmt.Printf("%g\n", boilingF-CToF(FreezingC)) // "180" °F
	//!-arith
}
/*
	//!+arith
	fmt.Printf("%g\n", boilingF-FreezingC)       // compile error: type mismatch
	//!-arith
*/
Output:

100
180
Example (Two)
//!+printf
c := FToC(212.0)
fmt.Println(c.String()) // "100°C"
fmt.Printf("%v\n", c)   // "100°C"; no need to call String explicitly
fmt.Printf("%s\n", c)   // "100°C"
fmt.Println(c)          // "100°C"
fmt.Printf("%g\n", c)   // "100"; does not call String
fmt.Println(float64(c)) // "100"; does not call String
//!-printf
Output:

100°C
100°C
100°C
100°C
100
100

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Celsius

type Celsius float64

Celsius 摄氏温度

const (
	// AbsoluteZeroC 绝对零度
	AbsoluteZeroC Celsius = -273.15
	// FreezingC 结冰点温度
	FreezingC Celsius = 0
	// BoilingC 沸水温度
	BoilingC Celsius = 100
)

func FToC

func FToC(f Fahrenheit) Celsius

func (Celsius) String

func (c Celsius) String() string

type Fahrenheit

type Fahrenheit float64

Fahrenheit 华氏温度

func CToF

func CToF(c Celsius) Fahrenheit

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL