Last active
October 15, 2017 11:51
-
-
Save paullaffitte/c55ad83db84c9be83cd1c5e5072e743f to your computer and use it in GitHub Desktop.
How to code my get number float at Epitech (require my_get_number or atoi and my_power_rec or my_power_it or pow)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
integer = my_getnbr(str) | |
str = str after the '.' character | |
decimal = my_getnbr(str) | |
decimal = decimal / 10^(strlen(str)) * (1 if number is strictly positive, -1 else) | |
number = integer + decimal | |
example: | |
[line] [values] | |
[1] str = '-13.04' integer = -13 | |
[2] str = '04' integer = -13 | |
[3] str = '04' integer = -13 decimal = 4 | |
[4] str = '04' integer = -13 decimal = 4 / 10^2 * -1 = 4 / 100 * -1 = -0.04 | |
[5] str = '04' integer = -13 decimal = -0.04 number = -13 + -0.04 = -13.04 | |
number = -13.04 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment