PBP does not support floats. So, converting those numbers will be difficult.
However, if like a challenge, this is a rough draft of how I would try my hand at it. This is not the best code that can be written for this though; just a pointer.
This is purely 'pseudo code' and not PBP though it looks a bit alike. At the end of this routine, you should have 4 values - Integer result, Fractional Result, Exponent and Units either V or A. Now, you combine them as you deem fit and have your resulting answerCode:IntResult = 0 FractionResult = 0 Exponent = 0 Units = "" WhichPart = 0 ' 0 = Integer part, 1 = fractional part, 2 = exponent part ExpFlag = 0 ' set to 1 when reading the exponent Pointer = points to start of number while (character@Pointer != end of string) select case WhichPart case IntPart: ' whichpart = 0 IntResult = IntResult * 10 select case character@pointer case "0" to "9": IntResult = IntResult + (character@pointer-'0') case "." WhichPart = 1 ' now on, gather fractional part end select case FractionalPart: ' whichpart = 1 FractionResult = FractionResult * 10 select case character@pointer case "0" to "9": FractionResult = FractionResult + (character@pointer-'0') case "e" OR "E": WhichPart = 2 ' now on, gather Exponent end select case ExponentPart: ' whichpart = 2 Exponent = Exponent*10 select case character@pointer case "0" to "9": Exponent = Exponent + (character@pointer-'0') case else Units = character@pointer end select end select ' move to the next character increment Pointer by 1 wend
Regards





Bookmarks