ποΈ Task Description
Summary
Add a feature that lets users type decimal numbers like 2.5 or -1.1 into commands they enter.
Details
Right now, users can only enter integer values in commands. For this issue, add the ability to enter non-integer values (i.e. floats).
To fully implement this feature, you will only need to change three functions: parse_int, get_implied_type, and parse_send.
Here are some starter to-do items:
- Rename
parse_int to parse_number and make the return value anything (because we're parsing any numbers now).
- In
parse_number, detect if the string contains a decimal number. This can be achieved by searching for a dot either at the start, the end, or between two other numbers (e.g. 30., .30 and 30.0).
- If it is a decimal number, convert the string into its encoded value as a float.
- If it's not a decimal number, defer to the existing integer detection code.
- In
get_implied_type, accept a string instead and add a check to determine if the string encodes a float
- If it is a float, return
"f32".
- Lastly, you'll have to appropriately encode the final values as bytes and add them to the
data bytearray (in parse_send).
β
Completion Criteria
π Affected Components
- Only
parser.py should be affected.
π§ Notes / Reference
ποΈ Task Description
Summary
Add a feature that lets users type decimal numbers like 2.5 or -1.1 into commands they enter.
Details
Right now, users can only enter integer values in commands. For this issue, add the ability to enter non-integer values (i.e. floats).
To fully implement this feature, you will only need to change three functions:
parse_int,get_implied_type, andparse_send.Here are some starter to-do items:
parse_inttoparse_numberand make the return value anything (because we're parsing any numbers now).parse_number, detect if the string contains a decimal number. This can be achieved by searching for a dot either at the start, the end, or between two other numbers (e.g.30.,.30and30.0).get_implied_type, accept a string instead and add a check to determine if the string encodes a float"f32".databytearray (inparse_send).β Completion Criteria
π Affected Components
parser.pyshould be affected.π§ Notes / Reference