I need to be as close as possible to 0. I need to split this value, but it should be effectively 0.
Is Java an easy way to generate a double with a minimum significant bit? Or should I figure it out myself?
// EDIT: some background information because someone asked for it. I know that my soul is not particularly pure, but here you are:
I am writing a program for homework. It calculates the resistance of a circuit consisting of several resistors in parallel and serial circuits.
This is the 2nd year programming class. Our teacher is still developing classes for us, we need to implement them in accordance with his design.
Parallel circuits include calculation 1/*resistance*, so my program prohibits the creation of resistors with 0 ohms. Physics tells you that this is not possible in any case (you only have a small resistance in each metal).
However, the sample circuit we should use to test the program contains a 0 ohm resistor. It is placed in a serial circuit, but the resistors do not know where they are (the teacher designed it this way), so I can not change my program to allow resistors with a resistance of 0 ohms only in serial circuits.
Two solutions:
- Allow 0 ohm resistors anyway - if division by 0 occurs, well, failure
- Set the resistor not to 0, but to the resistance, which can be neglected.
. , , .
, . , , ; -)