Page 1 of 1
StrD round problem
Posted: Mon Mar 28, 2011 9:56 pm
by mx101
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
Re: StrD round problem
Posted: Mon Mar 28, 2011 10:04 pm
by STARGĂ…TE
Code: Select all
dH.d = 23.976
dT.d = dH.d *1
Debug StrD(dT)
note:
Code: Select all
dH.d = 23.976
dT.d = dH.d *1
Debug StrD(dT,2)
bug in your code ?
Re: StrD round problem
Posted: Tue Mar 29, 2011 12:18 am
by netmaestro
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
Re: StrD round problem
Posted: Tue Mar 29, 2011 3:56 am
by mx101
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
you are right when Supply 3 show the correct result.
if supply only 2 round up result.
thanks
