Mercurial > repos > tabletprog
comparison modules/string.tp @ 339:74cab9b5f2a4
Added parseFloat64 and parseFloat32 along with a sample that exercises number parsing from a string
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 04 Apr 2015 12:34:43 -0700 |
parents | 8dbb2d2522a5 |
children | 6871e72b6db2 |
comparison
equal
deleted
inserted
replaced
338:1458c069c715 | 339:74cab9b5f2a4 |
---|---|
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 num | 146 num |
147 } | 147 } |
148 | |
149 llMessage: parseFloat64 withVars: { | |
150 fret64 <- obj_float64 ptr | |
151 } andCode: { | |
152 //TODO: This should probably detect non-numeric values and return an option type | |
153 fret64 <- make_object: (addr_of: obj_float64_meta) NULL 0 | |
154 fret64 num!: (atof: data) | |
155 fret64 | |
156 } | |
157 | |
158 parseFloat32 <- { | |
159 parseFloat64 f32 | |
160 } | |
148 | 161 |
149 llMessage: hash withVars: { | 162 llMessage: hash withVars: { |
150 intret <- (obj_int32 ptr) | 163 intret <- (obj_int32 ptr) |
151 i <- uint32_t | 164 i <- uint32_t |
152 } andCode: { | 165 } andCode: { |