const GAS_MARK_TABLE = [ { mark: "1/4", c: 110, f: 225 }, { mark: "1/2", c: 120, f: 250 }, { mark: "1", c: 140, f: 275 }, { mark: "2", c: 150, f: 300 }, { mark: "3", c: 170, f: 325 }, { mark: "4", c: 180, f: 350 }, { mark: "5", c: 190, f: 375 }, { mark: "6", c: 200, f: 400 }, { mark: "7", c: 220, f: 425 }, { mark: "8", c: 230, f: 450 }, { mark: "9", c: 240, f: 475 } ]; function nearestGasMark(celsius) { let best = GAS_MARK_TABLE[0]; let bestDiff = Math.abs(GAS_MARK_TABLE[0].c - celsius); for (const row of GAS_MARK_TABLE) { const diff = Math.abs(row.c - celsius); if (diff < bestDiff) { best = row; bestDiff = diff; } } return best.mark; } module.exports = { slug: "oven-temperature-conversion", title: "Oven temperature conversion", deck_category: "cooking", description: "Converts an oven temperature between Fahrenheit and Celsius, finds the nearest UK gas mark, and gives the standard fan-oven adjustment.", inputs: [ { name: "temperature", type: "number", required: true, description: "Oven temperature value" }, { name: "unit", type: "string", required: true, description: "Unit of the given temperature", enum: ["F", "C"] } ], outputs: [ { name: "celsius", unit: "C", description: "Temperature in Celsius" }, { name: "fahrenheit", unit: "F", description: "Temperature in Fahrenheit" }, { name: "gas_mark", unit: null, description: "Nearest UK gas mark from the cited table" }, { name: "fan_oven_celsius", unit: "C", description: "Suggested fan (convection) oven temperature, conventional minus 20 C" } ], steps: [ "If given in Fahrenheit: celsius = (fahrenheit - 32) * 5 / 9. If given in Celsius: fahrenheit = celsius * 9 / 5 + 32.", "Round celsius and fahrenheit to the nearest whole degree.", "gas_mark is the entry in the cited gas mark table whose Celsius value is nearest to the rounded celsius value.", "Fan (convection) ovens run hotter than conventional (static) ovens; the standard adjustment is to reduce the conventional Celsius temperature by about 20 C (or the Fahrenheit temperature by about 25 F) for a fan oven.", "fan_oven_celsius = celsius - 20, rounded to the nearest whole degree." ], constants: [ { name: "gas_mark_1_4_c", value: 110, unit: "C", source: 0 }, { name: "gas_mark_1_2_c", value: 120, unit: "C", source: 0 }, { name: "gas_mark_1_c", value: 140, unit: "C", source: 0 }, { name: "gas_mark_2_c", value: 150, unit: "C", source: 0 }, { name: "gas_mark_3_c", value: 170, unit: "C", source: 0 }, { name: "gas_mark_4_c", value: 180, unit: "C", source: 0 }, { name: "gas_mark_5_c", value: 190, unit: "C", source: 0 }, { name: "gas_mark_6_c", value: 200, unit: "C", source: 0 }, { name: "gas_mark_7_c", value: 220, unit: "C", source: 0 }, { name: "gas_mark_8_c", value: 230, unit: "C", source: 0 }, { name: "gas_mark_9_c", value: 240, unit: "C", source: 0 }, { name: "fan_oven_reduction_c", value: 20, unit: "C", source: 1 } ], sources: [ { kind: "edition_page", value: "Rombauer IS, Becker MR, Becker E. The Joy of Cooking, 2006 edition, oven temperature and gas mark conversion table, p. 3.", title: "Standard Fahrenheit/Celsius/gas mark oven temperature table", publisher: "Scribner", retrieved_utc: "2026-09-30T19:55:00Z", note: "Source of the gas mark to Celsius/Fahrenheit correspondence used here." }, { kind: "url", value: "https://www.which.co.uk/reviews/built-in-ovens/article/oven-temperature-conversion-table-aA5Ol9b157On", title: "Oven Temperature Conversion Table", publisher: "Which? (Which? Ltd, UK Consumers' Association)", retrieved_utc: "2026-09-30T22:29:13Z", note: "Confirmed table matches this card exactly: gas mark 4 = 350F/180C/160C fan, gas mark 6 = 400F/200C/180C fan, gas mark 7 = 425F/220C/200C fan; the page also states fan ovens run about 20C cooler than conventional ovens." } ], disclaimer: null, questionText(inputs) { return `What is ${inputs.temperature} degrees ${inputs.unit} in the other temperature scale, the nearest gas mark, and the fan-oven adjusted temperature?`; }, run(inputs) { const { temperature, unit } = inputs; if (typeof temperature !== "number") throw new Error("temperature must be a number"); let celsiusRaw, fahrenheitRaw; if (unit === "F") { fahrenheitRaw = temperature; celsiusRaw = (temperature - 32) * 5 / 9; } else if (unit === "C") { celsiusRaw = temperature; fahrenheitRaw = (temperature * 9) / 5 + 32; } else { throw new Error("unit must be F or C"); } const celsius = Math.round(celsiusRaw); const fahrenheit = Math.round(fahrenheitRaw); const gasMark = nearestGasMark(celsius); const fanOvenCelsius = Math.round(celsius - 20); const answer = `${celsius} C / ${fahrenheit} F, gas mark ${gasMark}, fan oven ${fanOvenCelsius} C`; return { answer, values: { celsius, fahrenheit, gas_mark: gasMark, fan_oven_celsius: fanOvenCelsius } }; }, examples: [ { name: "worked example", inputs: { temperature: 180, unit: "C" }, expected: { answer: "180 C / 356 F, gas mark 4, fan oven 160 C" }, check: "180*9/5+32 = 324+32 = 356. Nearest gas mark table entry to 180 C is gas mark 4 (180 C) exactly. Fan oven = 180-20 = 160." }, { name: "test vector: Fahrenheit input", inputs: { temperature: 425, unit: "F" }, expected: { answer: "218 C / 425 F, gas mark 7, fan oven 198 C" }, check: "(425-32)*5/9 = 393*5/9 = 218.333, rounds to 218. Nearest gas mark table entry to 218 C is gas mark 7 (220 C), diff 2, closer than gas mark 6 (200 C, diff 18). Fan oven = 218-20 = 198." } ] };