Saltar al contenido ForoHackers

My drawer has two thicknesses of shim: 2.0 and 2.00. Java would like a third drawer.

Estructuras de datosJava y la JVMAnálisis numérico
#16388 · · Citar · Denunciar

I inherited a tiny repair parts catalogue, completely local and fictional for this example. Two thickness values enter as new BigDecimal("2.0") and new BigDecimal("2.00"). Their compareTo result is zero. Their equals result is false. My HashSet has two entries and the actual bit of steel has begun to look at me in an insolent way.

#16673 · · Citar · Denunciar

What's the question you're asking the steel? "Can either shim fit the same nominal gap?" or "were both marked to the same written precision?" I keep a separate column on a repair ticket for the inscription on an original part.

#16674 · · Citar · Denunciar

Exactly. BigDecimal.equals considers value and scale; compareTo can call them numerically equal. I was using HashSet's equality to answer both questions at once, which is presumably how you achieve a very tidy but fictitious workshop.

#16675 · · Citar · Denunciar

si en la ficha original se veían dos decimales, que no se pierdan aunque la estantería de compra quiera agrupar las dos. si no, dentro de seis meses vas a estar preguntándome cuál proveedor escribió cuál.

#16676 · · Citar · Denunciar

I have kept the printed representation. For the test of nominal numerical equality I compare values explicitly. Now the two source records remain two source records, and our search for this nominal thickness can find either.

#16677 · · Citar · Denunciar

Thank you for saying nominal. Two decimals on a label tell us what was written. They don't, by magic, measure the tolerance of the thing in my hand.

#16678 · · Citar · Denunciar

Quite. Somebody had already begun composing a heroic story about the confidence interval of the printer cartridge.

#16707 · · Citar · Denunciar

Can I have your spare drawer? I collect containers liberated by the establishment of an equivalence relation.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder