Maths - precision
Posted: Tue Jul 11, 2017 9:32 pm
I am attempting to convert a maths expression form LCS to LCB as my first attempt at doing more than "Hello World" with LCB. The complex part of original LC script is
My LCB version is failing but it is correctly calculating a value for a.
LCB
The script version calculates a to be 7.61524e-05 whereas the LCB version logs 0.000076. It seems that LCB is not working to as many decimal places, is this the case or is it a function of the logging process.
While I am new to LCB I am left wondering why I might want to use it for general functions instead of a LC library script as it is the type of language environment that I was pleased to leave behind when I discovered Livecode and seems clumsy in comparison e.g. debugging the second complex line of maths is proving to be time consuming and may only serve to highlight a limitation in the precision of the maths functions.
Any thoughts?
best wishes
Simon
Code: Select all
put (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2 into a
put 2 * atan2( sqrt(a),sqrt(1-a)) into c
LCB
Code: Select all
put (sin(tChLat/2))^2 + cos(tLat1) * cos(tlat2) * (sin(tChLon/2))^2 into tFactorA
log "tFactorA is"
log tFactorA
put 2 * atan2(((tFactorA)^(0.5)),((1-tFactorA)^(0.5))) into tFactorC
log "tFactorC is"
log tFactorC
While I am new to LCB I am left wondering why I might want to use it for general functions instead of a LC library script as it is the type of language environment that I was pleased to leave behind when I discovered Livecode and seems clumsy in comparison e.g. debugging the second complex line of maths is proving to be time consuming and may only serve to highlight a limitation in the precision of the maths functions.
Any thoughts?
best wishes
Simon