I saw an example where the following code is used to convert double to float:
Double.valueOf(someDouble).floatValue()
I would just do it like
(float)someDouble
Is there an advantage to using the first?
Looking at the implementation Double floatValue():
Double
floatValue()
/** * Returns the value of this {@code Double} as a {@code float} * after a narrowing primitive conversion. * * @return the {@code double} value represented by this object * converted to type {@code float} * @jls 5.1.3 Narrowing Primitive Conversions * @since JDK1.0 */ public float floatValue() { return (float)value; }
It looks like it behaves exactly the same as your casting. Therefore, it makes no sense to use it.
Source: https://habr.com/ru/post/1669142/More articles:@Autowire Π² ΡΠΎΡΠ΅ΡΠ°Π½ΠΈΠΈ Ρ @InjectMocks - spring-bootWhy does OnSeekBarChangeListener always return the boolean false? - androidReliable JS rounding numbers with toFixed (2) of 3 decimal numbers - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1669140/how-can-i-add-optional-named-parameters-to-a-typescript-function-parameter&usg=ALkJrhi0oE7A7INlANsN0pZEkL3cYnWsqgEffective rope re-mixing - algorithmProblems with RecyclerView: EditText loses focus - androidAdding a new Viewcontroller view as a subtask - iosAPI routing error. Several actions were found that match the query with various API paths - c #Google Smart Lock for Facebook Login - androidConvert date string with timezone to era - pythonAll Articles