From e7b3a4e1c7c474a5cfdd2f824e9dad6d8af090cd Mon Sep 17 00:00:00 2001 From: Louis Caron Date: Sat, 10 Aug 2024 15:57:02 +0200 Subject: [PATCH] doc: why float can be described using 0x --- a2lfile/src/parser.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/a2lfile/src/parser.rs b/a2lfile/src/parser.rs index ae0d9f6..37e7af0 100644 --- a/a2lfile/src/parser.rs +++ b/a2lfile/src/parser.rs @@ -598,6 +598,9 @@ impl<'a> ParserState<'a> { pub(crate) fn get_float(&mut self, context: &ParseContext) -> Result { let token = self.expect_token(context, A2lTokenType::Number)?; let text = self.get_token_text(token); + // some vendor tools are defining the characteristic UpperLimit and LowerLimit + // (float values from specifications) using 0xNNN for characteristics that + // are actually integers. if text.starts_with("0x") || text.starts_with("0X") { match u64::from_str_radix(&text[2..], 16) { Ok(num) => Ok(num as f32), @@ -617,6 +620,9 @@ impl<'a> ParserState<'a> { pub(crate) fn get_double(&mut self, context: &ParseContext) -> Result { let token = self.expect_token(context, A2lTokenType::Number)?; let text = self.get_token_text(token); + // some vendor tools are defining the characteristic UpperLimit and LowerLimit + // (float values from specifications) using 0xNNN for characteristics that + // are actually integers. if text.starts_with("0x") || text.starts_with("0X") { match u64::from_str_radix(&text[2..], 16) { Ok(num) => Ok(num as f64),