From cd7ed4f9f9590f82acf953bba8d6032e1f62fa0c Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Fri, 5 Sep 2014 20:47:18 -0500 Subject: Couple changes to C to close https://github.com/adambard/learnxinyminutes-docs/pull/594 --- c.html.markdown | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/c.html.markdown b/c.html.markdown index 79b7aec7..cbb6d289 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -4,6 +4,7 @@ filename: learnc.c contributors: - ["Adam Bard", "http://adambard.com/"] - ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"] + - ["Jakub Trzebiatowski", "http://cbs.stgn.pl"] --- @@ -175,6 +176,9 @@ int main() { i2 * i1; // => 2 i1 / i2; // => 0 (0.5, but truncated towards 0) + // You need to cast at least one integer to float to get a floating-point result + (float)i1 / i2 // => 0.5f + i1 / (double)i2 // => 0.5 // Same with double f1 / f2; // => 0.5, plus or minus epsilon // Floating-point numbers and calculations are not exact @@ -194,9 +198,11 @@ int main() { 2 >= 2; // => 1 // C is not Python - comparisons don't chain. - // WRONG: - //int between_0_and_2 = 0 < a < 2; - // Correct: + // Warning: The line below will compile, but it means `(0 < a) < 2`. + // This expression is always true, because (0 < a) could be either 1 or 0. + // In this case it's 1, because (0 < 1). + int between_0_and_2 = 0 < a < 2; + // Instead use: int between_0_and_2 = 0 < a && a < 2; // Logic works on ints -- cgit v1.2.3 From 64c1ee391f4e03f363fd829ce658fc881bcffb6f Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Fri, 5 Sep 2014 20:48:42 -0500 Subject: Add lua-cn filename to close https://github.com/adambard/learnxinyminutes-docs/pull/610/files --- zh-cn/lua-cn.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/zh-cn/lua-cn.html.markdown b/zh-cn/lua-cn.html.markdown index 95a94c76..3ba098ec 100644 --- a/zh-cn/lua-cn.html.markdown +++ b/zh-cn/lua-cn.html.markdown @@ -9,6 +9,7 @@ contributors: - ["Amr Tamimi", "https://amrtamimi.com"] translators: - ["Jakukyo Friel", "http://weakish.github.io"] +filename: lua-cn.lua --- ```lua -- cgit v1.2.3 From eefa3add633ef1e80fb7403eec7854da1077188b Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Fri, 5 Sep 2014 20:51:48 -0500 Subject: Add traditional for loop bash example to close https://github.com/adambard/learnxinyminutes-docs/pull/654 --- bash.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bash.html.markdown b/bash.html.markdown index 57fb5c55..dc7d32b6 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -8,6 +8,7 @@ contributors: - ["Denis Arh", "https://github.com/darh"] - ["akirahirose", "https://twitter.com/akirahirose"] - ["Anton Strömkvist", "http://lutic.org/"] + - ["Rahil Momin", "https://github.com/iamrahil"] filename: LearnBash.sh --- @@ -140,6 +141,12 @@ do echo "$VARIABLE" done +# Or write it the "traditional for loop" way: +for ((a=1; a <= 3; a++)) +do + echo $a +done + # They can also be used to act on files.. # This will run the command 'cat' on file1 and file2 for VARIABLE in file1 file2 -- cgit v1.2.3 From b35ccf01af17b52447c98d7101ee932e7f089c52 Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Fri, 5 Sep 2014 20:59:37 -0500 Subject: Add FZSS's GitHub profile link to close https://github.com/adambard/learnxinyminutes-docs/pull/666 --- zh-cn/markdown-cn.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/markdown-cn.html.markdown b/zh-cn/markdown-cn.html.markdown index 975ebcb5..f1166a04 100644 --- a/zh-cn/markdown-cn.html.markdown +++ b/zh-cn/markdown-cn.html.markdown @@ -3,7 +3,7 @@ language: Markdown contributors: - ["Dan Turkel", "http://danturkel.com/"] translators: - - ["Fangzhou Chen"] + - ["Fangzhou Chen","https://github.com/FZSS"] filename: learnmarkdown-cn.md lang: zh-cn --- -- cgit v1.2.3