hi again...
i have a problem when i convert a double number to string.
here is an example:
i have
dH.d = 23.976
dT.d = dH.d *1
SetGadgetText(1, StrD(dT.d), 2)
always show as result 23.98
but i whant show 23.976*1= 23.976
I don't want to round this number
anyone can help me
StrD round problem
Re: StrD round problem


Code: Select all
dH.d = 23.976
dT.d = dH.d *1
Debug StrD(dT)
Code: Select all
dH.d = 23.976
dT.d = dH.d *1
Debug StrD(dT,2)
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: StrD round problem
Supply 3 for the NbDecimals parameter of StrD():
Code: Select all
dH.d = 23.976
dT.d = dH.d *1
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
TextGadget(1,10,10,200,20,"")
SetGadgetText(1, StrD(dT.d, 3))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
BERESHEIT
Re: StrD round problem
you are right when Supply 3 show the correct result.netmaestro wrote:Supply 3 for the NbDecimals parameter of StrD():Code: Select all
dH.d = 23.976 dT.d = dH.d *1 OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) TextGadget(1,10,10,200,20,"") SetGadgetText(1, StrD(dT.d, 3)) Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
if supply only 2 round up result.
thanks
