B4J Question [BANano] Operations with parentheses

angel_

Well-Known Member
Licensed User
Longtime User
When I do the following operations it seems to return an incorrect value:

B4X:
    Log(SinD((180 - 120) / 2))            'return 0.4330127018922193
    Log(Sin((cPI - cPI * 2 / 3) / 2))    'return 0.4330127018922193
    Log(Sin((cPI - (cPI * 2 / 3)) / 2))    'return 0.5, correct
    Log(SinD(30))                        'return 0.49999999999999994, correct
    Log((180 - 120) / 2)                'return 30, correct
 
Solution
It looks like there is a problem with the BANano parser with the parantheses. It should work like B4J but it somehow closes them to early when transpiling to the JavaScript Math functions. Will require a deeper investigation why this does happen.

For now, maybe simplify it by putting it in a variable before passing it to one of these Math methods (temp solution until I find the culprit)
B4X:
Dim sinValue As Double = (cPI - cPI * 2 / 3) / 2
Log(Sin(sinValue))

alwaysbusy

Expert
Licensed User
Longtime User
It looks like there is a problem with the BANano parser with the parantheses. It should work like B4J but it somehow closes them to early when transpiling to the JavaScript Math functions. Will require a deeper investigation why this does happen.

For now, maybe simplify it by putting it in a variable before passing it to one of these Math methods (temp solution until I find the culprit)
B4X:
Dim sinValue As Double = (cPI - cPI * 2 / 3) / 2
Log(Sin(sinValue))
 
Upvote 0
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…