|
Post by bplus on Dec 5, 2021 15:05:33 GMT -5
Percent = Int(number of hits * 100 / shots fired)
Should round it nicely to Integer amount.
|
|
johnno56
Junior Member
Logic is the beginning of wisdom.
Posts: 85
|
Post by johnno56 on Dec 5, 2021 17:20:35 GMT -5
Int works fine for 'whole' numbers... But, a decimal place or two, adds a little 'character'... (imho) lol - The tip is appreciated.
Yeah. I noticed QB64 is down again... Mud-wrestler's undies... lol
|
|
|
Post by bplus on Dec 5, 2021 18:23:05 GMT -5
Int works fine for 'whole' numbers... But, a decimal place or two, adds a little 'character'... (imho) lol - The tip is appreciated. Yeah. I noticed QB64 is down again... Mud-wrestler's undies... lol OK so you want to control number of places. Does this translate to RC? x# = 1234.123456789 For decimalPlaces = -2 To 6 Print xDP$(x#, decimalPlaces) Next
Function xDP$ (x As Double, DP As Integer) Dim test$, p As Long test$ = _Trim$(Str$(Int(x * 10 ^ DP) / 10 ^ DP)) p = InStr(test$, ".") If p = 0 And DP <> 0 Then test$ = test$ + "." + String$(DP, "0") If p And DP = 0 Then test$ = Left$(test$, Len(test$) - 1) xDP$ = test$ End Function
|
|
johnno56
Junior Member
Logic is the beginning of wisdom.
Posts: 85
|
Post by johnno56 on Dec 5, 2021 21:49:02 GMT -5
RC does not apply attributes (like double and integer) in function commands but could probably convert it.
Thanks for the code. By the way, Interesting colour theme you have there...
J
|
|