rspec/rules/S2127/java/rule.adoc

34 lines
788 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
``++Double.longBitsToDouble++`` expects a 64-bit, ``++long++`` argument. Pass it a smaller value, such as an ``++int++`` and the mathematical conversion into a ``++double++`` simply won't work as anticipated because the layout of the bits will be interpreted incorrectly, as if a child were trying to use an adult's gloves.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
int i = 42;
double d = Double.longBitsToDouble(i); // Noncompliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this "Double.longBitsToDouble" call.
'''
== Comments And Links
(visible only on this page)
=== on 10 Oct 2014, 14:07:37 Freddy Mallet wrote:
Perfect !
endif::env-github,rspecator-view[]