Monostatos
New Member
I have an application, written in C, working on a microprocessor with an LCD display. I am trying to convert it, using B4A, to run on a phone so that it can have a nice graphical display.
The particular problem that stumps me at present is that my square root routine, written to avoid using floating point arithmetic, fails to compile with this message:
If (work <= 1) Then Return retVal
src\b4a\example\calcs.java:329: error: unreachable statement
This is the code
Sub sqrti(inVal As Long) As Int
Private retVal = 1, work As Long
Do While (True)
retVal = (retVal + inVal / retVal) / 2
work = Abs((retVal * retVal) - inVal)
If (work <= 1) Then Return retVal
Loop
End Sub
Presumably the java compiler thinks that work can never be <=1. But a desk check shows it always converges to <=1. And the equivalent routine in C works fine.
I'd be grateful for any clues how to proceed. Where can I find the generated java code?
The particular problem that stumps me at present is that my square root routine, written to avoid using floating point arithmetic, fails to compile with this message:
If (work <= 1) Then Return retVal
src\b4a\example\calcs.java:329: error: unreachable statement
This is the code
Sub sqrti(inVal As Long) As Int
Private retVal = 1, work As Long
Do While (True)
retVal = (retVal + inVal / retVal) / 2
work = Abs((retVal * retVal) - inVal)
If (work <= 1) Then Return retVal
Loop
End Sub
Presumably the java compiler thinks that work can never be <=1. But a desk check shows it always converges to <=1. And the equivalent routine in C works fine.
I'd be grateful for any clues how to proceed. Where can I find the generated java code?