Recover from float parsing failure
ASPL 0.7.0 · Current release
Complete supplied source, preparation, and checked ASPL 0.7.0 outcomes.
On this page
Purpose and preparation
Browser and native, ASPL 0.7.0. Send 12x then 41. The f32 parse returns invalid-number; the f64 parse succeeds and prints 42. Status is 0.
See the current reference. No source module or external library is required.
Arabic source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["12x","41"]
دالة ابدأ_الرئيسية() -> ص64 {
اطبع("first: ").
دع سيئ: نتيجة<ع32> = حلل_ع32(اقرأ_سطر()).
إذا (سيئ::نجاح) {
أرجع 1.
}
اطبع(سيئ::الخطأ::الرمز).
اطبع("\سsecond: ").
دع جيد: نتيجة<ع64> = حلل_ع64(اقرأ_سطر()).
إذا (جيد::نجاح) {
إذا (نسق_ع64(0.5) لا يطابق "0.5") { أرجع 2. }
إذا (نسق_ع32(1.0000000596046448) لا يطابق "1.00000012") { أرجع 3. }
اطبع(نسق_ع64(جيد::قيمة + 1.0)).
اطبع("\س").
أرجع 0.
}
أرجع 4.
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "first: invalid-number\nsecond: 42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "first: invalid-number\nsecond: 42\n"
}
}English source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["12x","41"]
fn start_main() -> i64 {
print("first: ");
let invalid: result<f32> = parse_f32(read_line());
if (invalid::ok) {
return 1;
}
print(invalid::error::code);
print("\nsecond: ");
let valid: result<f64> = parse_f64(read_line());
if (valid::ok) {
if (format_f64(0.5) not match "0.5") { return 2; }
if (format_f32(1.0000000596046448) not match "1.00000012") { return 3; }
print(format_f64(valid::value + 1.0));
print("\n");
return 0;
}
return 4;
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "first: invalid-number\nsecond: 42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "first: invalid-number\nsecond: 42\n"
}
}Mixed source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["12x","41"]
fn ابدأ_الرئيسية() -> ص64 {
اطبع("first: ").
let سيئ: نتيجة<f32> = parse_f32(اقرأ_سطر()).
إذا (سيئ::ok) { أرجع 1. }
print(سيئ::الخطأ::code).
print("\nsecond: ").
دع جيد: result<ع64> = حلل_ع64(read_line()).
if (جيد::نجاح) {
إذا (format_f64(0.5) not match "0.5") { return 2. }
if (نسق_ع32(1.0000000596046448) not match "1.00000012") { أرجع 3. }
اطبع(نسق_ع64(جيد::value + 1.0)).
print("\n").
أرجع 0.
}
return 4.
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "first: invalid-number\nsecond: 42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "first: invalid-number\nsecond: 42\n"
}
}Check the result
The source cards show the catalog's exact inputs and outcomes. Locale changes do not translate the supplied source. Download retains original source bytes.