[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] StrMid(NumToStr(1040928),4,3);



PureBytes Links

Trading Reference Links

Stephane,

Why not just check what NumToStr returns before assuming bug ?

StrMid operates on STRINGs. You can get same results if strings passed are the same
in your case they are NOT. This is so because NumToStr by default returns strings
with thousand separators.

If you investigated a little bit more:

string=NumToStr(1040928); 
mm= StrMid(string,4,3); 
test= StrMid("1040928",4,3); 

you would find that NumToStr(1040928)
gives you sting like this:
"1,040,928.000"

As you can see there are thousands separators there.
Because "1,040,928.000" is different string than "1040928"
characters 4..6 are different too.

If you want string without separators you have to specify this in your 
NumToStr call http://www.amibroker.com/f?numtostr

string=NumToStr(1040928,1,False); 
mm= StrMid(string,4,3); 
test= StrMid("1040928",4,3); 

You can use StrFormat for more control http://www.amibroker.com/f?strformat

string=StrFormat("%.9g",1040928); 
mm= StrMid(string,4,3); 
test= StrMid("1040928",4,3); 

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Stephane Carrasset" <s.carrasset@xxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, December 17, 2004 6:12 PM
Subject: [amibroker] StrMid(NumToStr(1040928),4,3);


> 
> 
> Sorry to post all questions, but 
> mm returns 0.9
> and test returns 928
> is it a bug???
> 
> mm= StrMid(NumToStr(1040928),4,3);
> test= StrMid("1040928",4,3);
> 
> 
> 
> 
> 
> 
> Check AmiBroker web page at:
> http://www.amibroker.com/
> 
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/