Started by Swarnalata RoydebMay 4, 2022

Has anyone created a virtual host with apache and java?


As much as I have searched the web, I did not find information on how I could implement it together. The problem is that the containers I have run on localhost:8080 and what I'm looking for is to assign a domain to it.

1 Replies

Techiio-commentatorPrince Mishra replied 12 days ago0 likes0 dislikes

When we write

const x = 0.1

in a JavaScript source file and execute it, JavaScript does not interpret the 0.1 as the real number 0.1, because JavaScript numbers cannot represent every single possible real number, and 0.1 is not one of the real numbers which they can represent. Instead, 0.1 is interpreted as the closest JavaScript number to 0.1, which in binary is the number


or in decimal is


Note that there's nothing stopping us from writing all of those decimal digits out in our JavaScript source file if we want to:

const x = 0.1000000000000000055511151231257827021181583404541015625

JavaScript will always interpret what we wrote, no matter how (im)precise, as the closest available JavaScript number. Sometimes this reinterpretation will be absolutely precise. But sometimes this reinterpretation will lose some precision.

For the same reason, when we write

const y = 0.2

JavaScript does not interpret this as the real number 0.2 but as the real number


And if we write

const z = 0.3

JavaScript does not interpret this as the real number 0.3 but as the real number



This means that when we write

const sum = 0.1 + 0.2

(or const sum = x + y), what JavaScript actually computes is the precise sum

0.1000000000000000055511151231257827021181583404541015625 + 0.200000000000000011102230246251565404236316680908203125 = 0.3000000000000000166533453693773481063544750213623046875

JavaScript numbers cannot represent this precise result either, so the value returned is the closest available JavaScript number, which is


Again, we have lost a little precision, although for a different reason. At first, we lost some precision in the interpretation of the source code. Now, we have lost some more precision in the calculation.

Notice that this sum value, which we got by writing 0.1 + 0.2, is a different JavaScript number from what we got when we simply typed 0.3.


Now, what happens when we try to log any of these values at the console?

JavaScript does not log every last decimal place of a number. Instead, JavaScript logs out the minimum number of digits necessary to uniquely identify that JavaScript number from the other JavaScript numbers near it.

So, if we try to log the value


we'll see the much shorter three-character string

> 0.1

at our console, because this is all that is necessary.

Note that yet again, we have lost some precision! That's three times now!

Strictly speaking, the only reason why console.log(0.1) logs 0.1 is because of two different precision-loss events which cancel one another out. There is no 0.1 in the JavaScript programming language. One would be forgiven for thinking that there is.

Similarly, if we try to log


we'll get

> 0.2

out. And if we try to log


we'll get,

> 0.3

out. And finally, if we try to log the result of 0.1 + 0.2, which we remember is


we'll get [drum roll]

> 0.30000000000000004
You must be Logged in to reply

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance