Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!

# zheng li

Ranch Hand
since Jun 16, 2009
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
1
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by zheng li

thank you guys.
now i finally understand what "adjacent values" means.
10 years ago
double d = 2.3;
double d1 = 2.29999999999999982236431605997495353221893310546875;
System.out.println(String.format("%.100f", d));
System.out.println(String.format("%.100f", d1));
System.out.println(new BigDecimal(d));
System.out.println(new BigDecimal(d1));
// according to IEEE 754, 2.29999999999999937827510620991233736276626586914062
double d2 = 2.2999999999999996;
// according to IEEE 754, 2.29999999999999982236431605997495353221893310546875
double d3 = 2.2999999999999997;
System.out.println(String.format("%.100f", d2));
System.out.println(String.format("%.100f", d3));

OUTPUT:
2.3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2.3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2.29999999999999982236431605997495353221893310546875
2.29999999999999982236431605997495353221893310546875
2.2999999999999994000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2.3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

according to IEEE 754,
the really value of 2.3 stored in memory should be 2.29999999999999982236431605997495353221893310546875.
why are the first 2 lines 2.3?

it seems that java stores floating-point types in IEEE 754 format, but does some kind of rounding off when using them.
does anyone know why java deals with double this way?
is there any specification about it?

10 years ago
thank you.
10 years ago
BigDecimal a = new BigDecimal(2.3);
System.out.println(a);
OUTPUT:
2.29999999999999982236431605997495353221893310546875

a = new BigDecimal(String.valueOf(2.3));
System.out.println(a);
OUTPUT:
2.3

is it true that Double.toString() always returns exact value?
10 years ago
i am usint org.apache.commons.net.telnet.TelnetClient to invoke scripts on a remote server.
i wrote 2 scripts on the server.
one is
sleep 30;echo success;
the other is
echo success;sleep 30;echo success;

and i set time out to 15s
telnetClient.setSoTimeout(15000)

if i call the second script, timeout works just fine, and throw sockettimeout exception.
but if i call the first one, it seems timeout is set to 0 (wait infinite), and telnetClient will wait 30s for the response.

10 years ago
different browser settings for different internet/intranet regions?

how to do it?
10 years ago

mohammed sanaullah wrote:

zheng li wrote:i am not manage jsessionid myself.
just that i found this problem and don't understand why.

it seems that the two way of managing session id can not coexist.

Is it not that either URL Rewriting or Cookies are used for session management?

yes, you are right.
thank you.
10 years ago
i am not manage jsessionid myself.
just that i found this problem and don't understand why.

it seems that the two way of managing session id can not coexist.
10 years ago
sorry, my quesion was not clear enough.

i deployed the same application which has a login page on the server and my local computer.
but if i access
both server and local are http.

there is only tomcat on my local computer, but on the server, there are apache and tomcat.
10 years ago
i am using tomcat.
if i use jsessionid=617AA28660D5C1B1408543C24B186A75 in url to send session id to server, response does not put it in cookie, so if redirect happens, a completely new session will be created.

is it a bug or http specification?
i can't find anything about it in rfc though.

or is there any configuration about it in tomcat?
10 years ago
I don't know if here is the right place to ask this question.
if it is not, i apologize.

I know how to disable it by using javascript or tools->internet options.
the question is
if i deploy my application on local computer(window 2K), password can be remembered, and whenever i input username, password textbox will be filled automatically.
but when i deploy it on company's server(solaris), password can never be remembered.

is there any configuration about remembering password or not in tomcat or apache?
10 years ago
not as difficult as I thought.
I really prepared for a long time.
10 years ago

Henry Wong wrote:

zheng li wrote:
I know there are no guarantees that finalize method will run, so I don' understand why when i killed the java process, all database connections disappeared.
i don't think SimpleDataSource class has the chance to close the connections.

When a process terminates, the operating system frees all resources.

There is no need to run the GC because all allocated memory will be freed. There is no need to finalize the database connection, because the OS will close all files and network connections.

This is done for all applications, regardless of whether it is the JVM or not.

Henry

thank you.
i met something on windows like after i terminate a program, i can't delete the file the program has modified. so i always thought that i couldn' rely on OS.
but now it seems OS does some cleanup for us.
11 years ago
sorry that i didn't make my question clear.

I know there are no guarantees that finalize method will run, so I don' understand why when i killed the java process, all database connections disappeared.
i don't think SimpleDataSource class has the chance to close the connections.

11 years ago

Wouter Oet wrote:No

actually, i am using SimpleDataSource class in ibatis, and it releases all database connections in its finalize method.
i'm surprised that all database connections disappear even if i kill the java process.
i'm not sure when and how it does the job. so i asked the question.
11 years ago