由买买提看人间百态

topics

全部话题 - 话题: constant
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
R****d
发帖数: 27
1
来自主题: JobHunting版 - 搞不清C++里的constant expression
a global constant by default has internal linkage, and thus can be included
in header file.
constant express is integral only.
constant expression evaluates to const. const is not necessarily constant
expression.
so
const double pi=3.14 is a constant, not a constant expression.
In a test.hpp:
const double pd =3.14;// this is ok. 3.14 is const.
class X {
static const double pd =3.14;//Line A: this is error. 3.14 is not
constant expression
static const int pi = 3; // Line B: this is ok. 3 ... 阅读全帖
s******e
发帖数: 63
2
in one web application(resin server), I put string constants in one class
Constants, those string constants are like:
public final static String UPPER="...."
when other classes use this constants, just call Constants.UPPER etc.
but when I changed some string value, recompiled, even restarted resin server,
in the places where uses changed constants, it still uses old constants.
how could this happen? if changes was taken inside jsp, I could understant
there's some cache issue. do java classes als
s****A
发帖数: 80
3
来自主题: JobHunting版 - 搞不清C++里的constant expression
找到的所有定义都说必须是整型或转化为整型的,编译时可以evaluate to constant的
表达式
那照这种定义的话 const double pi=3.1415926
这里的3.1415926肯定就不是constant expression了
可是同一本书上又说When a const is initialized by a value that is not a
constant expression, 那它的define就不应该在头文件里
照这个条件的话上面的pi的定义就不能放在头文件里了
可是看到另外一个来源里明明就说const double pi=3.1415926应该放在头文件里
因为它是被constant expression初始化的
那么,到底一个小数算不算 constant expression?
OE
发帖数: 369
4
ldc是这样解释的:
Pushing a String causes a reference to a java.lang.String object to be
constructed and pushed onto the operand stack.
astore是这样解释的:
Pops objectref (a reference to an object or array) off the stack and stores
it in local variable
根据这篇文章http://mindprod.com/jgloss/interned.html#UNDERTHEHOOD
我是这样理解的:
那两个string ref.在ldc时就是相同的。与“Hello!”相对应的string object在class
loading的时候就生成了,而且会有一个weak string ref.(指向这个string object
)被放到一个hashmap里。这个hashmap有时就被称为string pool。当第二个class被
load
,或则说它的runtime c... 阅读全帖
OE
发帖数: 369
5
ldc是这样解释的:
Pushing a String causes a reference to a java.lang.String object to be
constructed and pushed onto the operand stack.
astore是这样解释的:
Pops objectref (a reference to an object or array) off the stack and stores
it in local variable
根据这篇文章http://mindprod.com/jgloss/interned.html#UNDERTHEHOOD
我是这样理解的:
那两个string ref.在ldc时就是相同的。与“Hello!”相对应的string object在class
loading的时候就生成了,而且会有一个weak string ref.(指向这个string object
)被放到一个hashmap里。这个hashmap有时就被称为string pool。当第二个class被
load
,或则说它的runtime c... 阅读全帖
s******e
发帖数: 63
6
we don't have big release. we add new partners to web application from time
to time, and need to keep web application running always since it's money
machine:)
previously these constants are defined in each partner specific classes so
there's
no issue. These constants are web service url of those partners so I tries
to seperate them out to Constants class, and use another staging version
Constants class for devo/staging server so testing won't be posted to partner
web service in devo/staging.now
OE
发帖数: 369
7
想知道JVM内部到底是如何实现string pool的。
string pool里存的到底是string objects还是string references?
string pool和class constant pool的关系是什么样的?
public class hello1{
public static String s="Hello!"
}
public class hello2{
public static void main (String[] args){
String s = "Hello!";
System.out.println(s==hello1.s);//this is true
}
}
if you check the constant pool in .class files, you can see both classes
have "#n = Utf8 Hello!" in their constant pool. 但我猜,当JVM load这两个
classes,它们各自的runtime constant pool把"Hello1"存成... 阅读全帖
OE
发帖数: 369
8
想知道JVM内部到底是如何实现string pool的。
string pool里存的到底是string objects还是string references?
string pool和class constant pool的关系是什么样的?
public class hello1{
public static String s="Hello!"
}
public class hello2{
public static void main (String[] args){
String s = "Hello!";
System.out.println(s==hello1.s);//this is true
}
}
if you check the constant pool in .class files, you can see both classes
have "#n = Utf8 Hello!" in their constant pool. 但我猜,当JVM load这两个
classes,它们各自的runtime constant pool把"Hello1"存成... 阅读全帖
m*****e
发帖数: 126
9
来自主题: Java版 - Re: Java Tip: Constant
I do not agree with some of your points.
1. Sometimes it is good practice to use interface to define constants.
A good example in JDK is the SwingConstants interface. It defined
many constants which are used elsewhere in javax.swing package.
2. About the naming confusion, I think the programer should be responsible
for this. If a programmer always names his variables as things like
'a' or 'b', surely he will have trouble from time to time.
3. If we name the constants properly, there
s******e
发帖数: 63
10
you meant other classes 'remember' old final constants during their
compilation
time? does this only happen to 'final static'? so if I use 'static', it should
solve the problem?
problem is that I could not always do clean build on production. we need
to keep it running always and only patch couple of classes from time to time
(for example, constants in Constant class may be changed)
s******e
发帖数: 63
11
don't see database/xml is easier to maintain in this case.
for database, you need to maintain different copy in production and staging;
for xml, you need to spend more time to check it's format or spelling.
for foreseeable future, total constants will be less than 30 and normally
only new constants to be added. I ask this question just in case one constant
would be changed...
e***s
发帖数: 799
12
求 Leetcode Online Judge Sort Color one pass constant space 解法。
Copy 下题目:
Given an array with n objects colored red, white or blue, sort them so that
objects of the same color are adjacent, with the colors in the order red,
white and blue.
Here, we will use the integers 0, 1, and 2 to represent the color red, white
, and blue respectively.
Note:
You are not suppose to use the library's sort function for this problem.
Follow up:
A rather straight forward solution is a two-pass algorithm using coun... 阅读全帖
v*********l
发帖数: 181
13
来自主题: EnglishChat版 - what is constant dollars
the distinction between constant dollars and current dollars was out of the
question altogether
what does constant dollars and current dollars mean?
c*****l
发帖数: 23
14
来自主题: EnglishChat版 - what is constant dollars
use google: "define:constant dollars"
The price paid for something in previous years, adjusted for inflation to
equal what the price would be in current dollars. Constant dollars permit
comparisons of the true cost of goods and services or other financial data
from different time periods.
xt
发帖数: 17532
15
来自主题: Java版 - Re: Java Tip: Constant

Yes, this works, but it is not a good idea.
First, it does not make sense to implement a constant interface.
Interface means ADT, and what does a constant interface mean?
Second, implementing such an interface gives rise to naming
clashes. For example:
public interface A {
public static final int a = 1;
}
public interface B {
public static final int a = 2;
}
If you implement both interfaces, there you have to think how
the a is evaluated. If you want to be specific, A.a, B.a is better
w
m******t
发帖数: 2416
16
来自主题: Java版 - Re: Java Tip: Constant

First of all, while we all agree the Java core classes can be used
as classic examples for certain patterns or feature usage, not every
single bit of them is so "holy" and indisputable.
In the case of SwingConstants (and also some IO classes mentioned
in some previous post), the purpose of this separate interface is
to define constants that are used in so many swing classes that it is
inappropriate to define them repeatedly in all those classes. However,
the designer didn't put *all* constants
g*****g
发帖数: 34805
17
It would be very unwise to assume urls don't change, as you see,
you are adding entries frequently. Put it in database, or put it
in an external xml if you worry about performance. I don't see how
it costs you more testing time? Isn't a constant just a constant,
be it in class, in xml or in database?
s******e
发帖数: 63
18

?then always no constants except something like 3.14159...:)
in your code, you are sure every constant will never be changed?
s******e
发帖数: 63
19
sorry, I thought you misunderstood.
"a couple of times a day" is not for changing/adding constants, but for
other changes. I said this to reply "always need to do a clean build" or
"shutdown server", not to reply constants problem.:)
m******t
发帖数: 2416
20

It's actually a good 'optimization' of java - the language spec says that
a constant should always be inlined if its value can be determined at
compile-time. It's intended to mimic the macro in C/C++ and encourage
programmers to use constants rather than literal values.
It's a little counter-intuitive, I agree, nonetheless a reasonable price
to pay for the performance gain.
m******t
发帖数: 2416
21

constant
I have gone through the whole conversation so far and agree with
goodbug. IMHO, your architecture is flawed on two accounts:
1. service URL's are not constants. In fact, the whole point of
using URL's to denote service points is to support dynamic
configuration.
2. You probably never, ever, want to do a partial update to your
production application. If your application can be or must be updated
partially, divide it into smaller deployment units and always do clean
build of one whole un
m******t
发帖数: 2416
22

[snip]
I completely agree with what you said here and below about "final",
but unless I misunderstood the OP, his problem is with constants, i.e.,
"static final", rather than just "final". I would say they are totally
different animals. 8-)
Section 13.4.8, JLS actually does dictate that "compiler-time constants",
i.e., static final variables be inlined, and even gives some explanation
as to the rationale behind this requirement.
t***a
发帖数: 416
23
我就是看了你的帖子,和你程序的结果,自己瞎联想的
constant pool(是叫这个名字么)是per class的,而且是runtime的,但是这个string
的instance肯定是整个jvm来share的,只有一个,那么constant pool里应该只存ref,
而且还是strong ref(它不能让这个instance被gc)
string pool是存soft ref的,它是所有classes共享的,如果所有class里的strong
ref都被回收了,那么string pool里面引用的这个string instance也会被回收的
这么看来。。。的确是不同的。。。。楼主为啥要比较他们两个呢?
t***a
发帖数: 416
24
我就是看了你的帖子,和你程序的结果,自己瞎联想的
constant pool(是叫这个名字么)是per class的,而且是runtime的,但是这个string
的instance肯定是整个jvm来share的,只有一个,那么constant pool里应该只存ref,
而且还是strong ref(它不能让这个instance被gc)
string pool是存soft ref的,它是所有classes共享的,如果所有class里的strong
ref都被回收了,那么string pool里面引用的这个string instance也会被回收的
这么看来。。。的确是不同的。。。。楼主为啥要比较他们两个呢?
b********d
发帖数: 720
25
比如(CH2F2)n,PVA之类已经发现可以用作organic dielectric的polymer
怎么算dielectric constant呢?
我知道怎么算polymer的HOMO-LUMO bandgap,可以大致判断一个polymer分子有没有作为
dielectric的可能性,不过更精确的dielectric constant呢? 怎么算?
谢谢!
g****n
发帖数: 7494
26
我在做用超声波讲解多糖
分别用Huggins和Kraemer来估算intrinsic viscosity[n]
Huggins:
nsp/C=[n]+K'[n]^2C
Kraemer:
ln(nrel)/C=[n}+K"[n]^2C
结果发现根据讲解时间的长短,Kraemer constant(K")一直是负值,Hugginsconstant(
K')开始时正值,后期变成负值
K'-K"的差值从0.5左右随着降解时间延长逐渐减小
搜了很多文献,都是讨论Huggins constant大于小于1的讨论,没有见过有讨论过正负的
所以,希望达人能帮忙解答一下
j******n
发帖数: 91
27
两个call. 一个constant volatility 40%, 一个stochastic volatility with mean
40%. 问两个哪个值钱。
option price is in most cases a convex function of volatility. 所以是由
convex property, constant volatility 的那个option 更值钱。对吗?
G*********o
发帖数: 2045
28
我现在的dataset是censored,但是censor level不是constant,而是每一个
observation有自己的censor level(比如第一个observation是left censor在0,第二
个observation是left censor在10,etc),并且这个censor level是known的。我想在
R里面用tobit model来给这组数据fit一个linear model,但是找了半天只看到有个
VGAM可以做tobit模型,但是只能接受constant censor level,请问有没有人知道其他
package可以用tobit model处理censored data的?包子答谢
O******1
发帖数: 13088
29
continuously暗含一波接一波的意思,可以用来形容女人性高潮连连。
constantly暗含保持恒定的意思,可以用来形容男人性能力持久。
i***a
发帖数: 4718
30
http://www.cnn.com/2017/02/14/politics/donald-trump-aides-russians-campaign/index.html
(CNN)High-level advisers close to then-presidential nominee Donald Trump
were in constant communication during the campaign with Russians known to US
intelligence, multiple current and former intelligence, law enforcement and
administration officials tell CNN.

发帖数: 1
31
More Americans report near-constant cannabis use
y*****6
发帖数: 1107
32
buyer email:"The Brother fax machine shows a constant busy signal. When
receiver is placed on hook the line is still bbusy.apparently there must be
something wrong with the machine. Any ideas?"
可能什么原因??
X**********g
发帖数: 480
33
【 以下文字转载自 Mathematics 讨论区 】
发信人: Xiaolingtong (小灵通), 信区: Mathematics
标 题: 矩阵A 满足 A+A'=C, where C is a constant
发信站: BBS 未名空间站 (Sat Apr 10 15:01:30 2010, 美东)
换句话说 A(i,j)+A(j,i) 总是个常数
这样的 矩阵 A 有什么性质么
d***d
发帖数: 24
34
constant trace --> invariant w.r.t. change of basis
s****A
发帖数: 80
35
来自主题: JobHunting版 - 搞不清C++里的constant expression
怎么会是string literal?
不是float 或者double literal吗?
但不管如何都不是integral type的啊,所以不符合书上关于constant expression的定义
a**********0
发帖数: 422
36
来自主题: JobHunting版 - Fibonacci数计算 要求constant time
更正 说错了 仍然不是constant time
a**********0
发帖数: 422
37
来自主题: JobHunting版 - Fibonacci数计算 要求constant time
对 可以使用类似公式的东西 可以用矩阵的SVD乘方的方法计算
但问题是需要计算常数的乘方 所以不算constant time
a*****8
发帖数: 26
38
Email me at [email protected]
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
if interested in.
How would you like to work with 150TB of data in Hadoop where you can derive
insights into the beha... 阅读全帖
s**l
发帖数: 11983
39
constant
l******u
发帖数: 2314
40
来自主题: CouchPotato版 - Lost 回顾: S4E05 "The Constant"
【出处:http://www.filmfodder.com/tv/lost/archives/004439.shtml
******************************************
Key Points from "The Constant"
******************************************
Season 4, Episode 5
Episode Air Date: 02/28/08
Point 1
c********n
发帖数: 122
41
来自主题: PhotoGear版 - Constant Light Versus Flash Light
Mark Wallace talks about constant light vs flash light:
http://www.youtube.com/watch?v=4QaCI_SUc5c&list=PL7DE50CFC19370
wh
发帖数: 141625
42
就是人都失去了求生的意志。open water里那个女的忍痛放手,让昏死的男人漂走,然
后自己沉下水面自杀。constant gardener里那个男的自感逃不出追杀者的手心,让飞
机把他投在鳄鱼湖边他老婆被杀的地方,一边怀念他老婆一边拿枪准备自杀。虽然最后
还是被追杀的人杀死,但死念早就已决。
这个让人看得很难受,很消沉。the professional那个电影里面,那个警察杀手都说,
他不杀没有求生意志的人,不杀求死的人。人都不求生了,给人感觉一点意义都没有了
。我更喜欢看那些即使很绝望、仍然尽力求生的电影,或者即使求死、仍然给人积极的
感觉,比如philadelphia——不知道这个例子对不对,我忘了那个艾滋病人最后怎么死
的了。
e*****n
发帖数: 244
43
来自主题: BIT版 - constant pool
I finally found out why the java program can not pass
the compilition. the co-exsiting same class in different
.java file make the constant pool can not find out the
finination of the class.
m***r
发帖数: 294
44
In array, getting or setting the value at a particular index (constant time)
.
Why?
e**c
发帖数: 195
45
想找下述文章,希望有好心人帮忙。
请发到我的信箱;e******[email protected]
多谢。
S. E. Decatur, “PAC Learning with Constant-Partition Classification Noise
and Applications to Decision Tree Induction”, ICML 1997.
http://portal.acm.org/citation.cfm?id=657273
xt
发帖数: 17532
46
来自主题: Java版 - Re: Java Tip: Constant
Just some personal follow up ideas:
It does not kill you if you type a little more to make the program
more readable and better in style. We have been using vi editor
to write everything (excluding GUI design sometimes, but some
people actually write PowerJ scripts with vi instead of using
the PowerJ GUI to design frames as well. Even my co-op student
knows how to do it). Implementing interfaces with nothing but
constants is bad idea in terms of software engineering.
More typing may cost you tim
m******t
发帖数: 2416
47
来自主题: Java版 - Re: Java Tip: Constant
I am with xt on this one. The basic point is, think about it
in OO way, that is, constants are also part of your data, rather
than just some macros in C. And you need to organize and encapsulate
your data into classes.
If you have either a good memory(which I don't have), or an IDE
supporting abbreviation/auto completion(which I do), typing long
variable names is never a big problem. 8-)
xt
发帖数: 17532
48
来自主题: Java版 - Re: Java Tip: Constant

Yes, there can be data members in interfaces. If the
interface is not
for constant definations only, there should be some methods
or semantic
features. In this case, the data members should be related
to the features
otherwise it does not make sense to put them there.
Considering following example, do you think it makes sense:
public interface MyConstants1 {
public static final int a = 1;
}
public interface MyConstants2 {
public static final int a = 2;
public static final int b = 3;
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)