From 0c014a23b44c4dce079be6067b4360ccae5637f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 18 Jun 2024 12:17:13 +0200 Subject: [PATCH] doc/coding-style: Update guidelines for floating point numbers The old guidelines aren't compatible with -Wfloat-conversion. Part-of: --- doc/coding-style.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/coding-style.md b/doc/coding-style.md index 7a2e67e73..f60a9a9bb 100644 --- a/doc/coding-style.md +++ b/doc/coding-style.md @@ -50,7 +50,12 @@ style][gnome-coding-style], with some additions described below. * Use `g_new0 ()` etc. instead of `g_slice_new0 ()`. * Initialize and assign floating point variables (i.e. `float` or - `double`) using the form `floating_point = 3.14159` or `ratio = 2.0`. + `double`) using the the correct precision format, and don't omit zeros. For example + ```c + float ratio = 2.0f; + double pi = 3.14159; + float fraction = 0.2f; + ``` ## Naming conventions