Skip to content

Commit 01be507

Browse files
authored
Merge pull request #20 from borsec-suveran/patch-17
Update 02_.md
2 parents 1a4088a + f1cce49 commit 01be507

File tree

1 file changed

+1
-1
lines changed
  • 02_Data Types and Variables/00_Data Types/04_Numbers Conversion

1 file changed

+1
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
The code above shows all three types of conversions we can use in our program. The first conversion from floating-point to integer is used when rounding is not considered. The conversion from floating-point to integer ignores truncates the decimal. The digits that come after the decimal point are ignored and the original number is not rounded during the process. If you want to round the floating point to an integer, all you have to do is to add 0.5 to the original value as shown above. This will round your floating-point 100% of the time.
1+
The code above shows all three types of conversions we can use in our program. The first conversion from floating-point to integer is used when rounding is not considered. The conversion from floating-point to integer truncates the decimal. The digits that come after the decimal point are ignored and the original number is not rounded during the process. If you want to round the floating point to an integer, all you have to do is to add 0.5 to the original value as shown above. This will round your floating-point 100% of the time.
22

33
Converting strings to integer requires a similar method of using `| 0`. If the string doesn't start with a digit, the conversion will not work.

0 commit comments

Comments
 (0)