Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: inbase and subinstr problem


From   "Sergiy Radyakin" <[email protected]>
To   <[email protected]>
Subject   st: Re: inbase and subinstr problem
Date   Wed, 21 Feb 2007 16:04:24 +0100

Hi,

the code below works, so I can suggest you can change your code accordingly. (Binary representation of 600000000 requires 30 digits)

-----------------------------------------------------------------------
inbase 2 600000000
global fff="`r(base)'"
di "$fff"
local hhh: subinstr global fff "1" "1", all count(local nnn)
di `nnn'
-----------------------------------------------------------------------


Regards, Sergiy



----- Original Message ----- From: "Nikolaos A. Patsopoulos" <[email protected]>
To: <[email protected]>
Sent: Wednesday, February 21, 2007 3:25 PM
Subject: st: inbase and subinstr problem



Hi all,

I'm working currently in a project implementing a part of Nick Cox's tuples program and I bumped into sth weird.

For values of local which with more than 17 digits subinstr fails to count all occurences of number "1". Below is a small code representative of the problem:



forval i = 65536/65537 {
inbase 2 `i'
local which : di %020.0f `r(base)'
local which : subinstr local which "1" "1", ///
all count(local n1)
di "r(base): " `r(base)'
di "which: "`which'
di "n1: " `n1'
}

Any ideas??

Thanks in advance,

Nikos
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index