store(ini): added floating point numbers
This commit is contained in:
parent
d2f9e4d8f7
commit
f5e9ec0cde
@ -166,6 +166,19 @@ ini_parse_and_set_pointer_by_base_type :: proc(ptr: rawptr, str: string, type_in
|
||||
}
|
||||
case runtime.Type_Info_Float:
|
||||
value := strconv.parse_f64(str) or_return
|
||||
switch type_info.id {
|
||||
case f16: (cast( ^f16)ptr)^ = cast( f16) value
|
||||
case f32: (cast( ^f32)ptr)^ = cast( f32) value
|
||||
case f64: (cast( ^f64)ptr)^ = value
|
||||
|
||||
case f16be: (cast(^f16be)ptr)^ = cast(f16be) value
|
||||
case f32be: (cast(^f32be)ptr)^ = cast(f32be) value
|
||||
case f64be: (cast(^f64be)ptr)^ = cast(f64be) value
|
||||
|
||||
case f16le: (cast(^f16le)ptr)^ = cast(f16le) value
|
||||
case f32le: (cast(^f32le)ptr)^ = cast(f32le) value
|
||||
case f64le: (cast(^f64le)ptr)^ = cast(f64le) value
|
||||
}
|
||||
case runtime.Type_Info_Integer:
|
||||
if type_info_variant.signed {
|
||||
value := strconv.parse_i128(str) or_return
|
||||
@ -279,6 +292,10 @@ ini_parse_and_set_pointer_by_base_type_success :: proc(t: ^te.T) {
|
||||
test_with_type_info(t, uint, "3", 3)
|
||||
test_with_type_info(t, uintptr, "3", 3)
|
||||
|
||||
test_with_type_info(t, f16, "0.125", 0.125)
|
||||
test_with_type_info(t, f32, "0.125", 0.125)
|
||||
test_with_type_info(t, f64, "0.125", 0.125)
|
||||
|
||||
test_with_type_info(t, bool, "true", true)
|
||||
test_with_type_info(t, b8, "true", true)
|
||||
test_with_type_info(t, b16, "true", true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user