Trace:

rounding_20functions

This shows you the differences between two versions of the page.

rounding_20functions [2018/03/31 14:19] 127.0.0.1 external edit |
rounding_20functions [2018/04/17 19:34] (current) tbest3112 Added syntax highlighting |
||
---|---|---|---|

Line 2: | Line 2: | ||

//by Richard Russell, June 2016//\\ \\ If you want to **round** a numeric value to a specific number of decimal places or significant figures there are a number of ways in which this can be achieved. The most flexible way is to use the [[http:// | //by Richard Russell, June 2016//\\ \\ If you want to **round** a numeric value to a specific number of decimal places or significant figures there are a number of ways in which this can be achieved. The most flexible way is to use the [[http:// | ||

+ | <code bb4w> | ||

DEF FNround_dp(n, | DEF FNround_dp(n, | ||

LOCAL @% | LOCAL @% | ||

Line 11: | Line 12: | ||

@% = & | @% = & | ||

= STR$(n) | = STR$(n) | ||

+ | </ | ||

It is perhaps worth emphasising that the concept of rounding to a certain number of digits applies only to decimal numbers, which is why the above functions return strings. BBC BASIC holds numeric values internally in binary, so you cannot meaningfully refer to them as being rounded to a certain number of decimal digits. | It is perhaps worth emphasising that the concept of rounding to a certain number of digits applies only to decimal numbers, which is why the above functions return strings. BBC BASIC holds numeric values internally in binary, so you cannot meaningfully refer to them as being rounded to a certain number of decimal digits. |

rounding_20functions.1522502378.txt.gz ยท Last modified: 2018/03/31 14:19 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International