Explanation

521.Convert Celsius to Fahrenheit

Easy
Given a temperature in degrees celsius, return the same temperature in Fahrenheit, formatted with two decimal places. The conversion multiplies by 9/5 and adds 32. It is a short formula with a classic trap for beginners: in Java, C and C++, 9 / 5 is integer divisionInteger DivisionDividing two whole numbers and keeping only the whole part — 9 / 5 gives 1, not 1.8. and equals 1. Both solutions avoid it — one by dividing by 5.0, the other by using the ready-made factor 1.8. Formatting to two decimals also hides the tiny floating-point errorFloating-Point ErrorA tiny inaccuracy caused because most decimal fractions (like 1.8) cannot be stored exactly in binary. that decimal arithmetic can leave behind.

Example 1:

Input: celsius = 37

Output: "98.60"

Example 2:

Input: celsius = -40

Output: "-40.00"

+ 6 hidden test cases run on Submit.

Constraints:

  • ●-273 ≤ celsius ≤ 1000

celsius =

37