Java Array Length Get length(long[] v)

Here you can find the source of length(long[] v)

Description

Returns the length of a vector

License

Open Source License

Parameter

Parameter Description
v the vector (Long)

Return

the length of the vector (Double)

Declaration

public static double length(long[] v) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w w w .java  2  s .c o m*/
     * Returns the length of a vector
     *
     * @param v the vector (Long)
     * @return the length of the vector (Double)
     */
    public static double length(long[] v) {
        return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
    }

    /**
     * Returns the length of a vector
     *
     * @param v the vector (Float)
     * @return the length of the vector (Float)
     */
    public static float length(float[] v) {
        return (float) Math.sqrt(v[0] * v[0] + v[1] * v[1]);
    }

    /**
     * Returns the length of a vector
     *
     * @param v the vector (Integer)
     * @return the length of the vector (Float)
     */
    public static float length(int[] v) {
        return (float) Math.sqrt(v[0] * v[0] + v[1] * v[1]);
    }
}

Related

  1. length(final Object[] array)
  2. length(final T[]... arrays)
  3. length(float[] color)
  4. length(int[] tail)
  5. length(int[][] instance, int u)
  6. length(Object anArray[])
  7. length(Object[] array)
  8. length(Object[] array)
  9. length(Object[] array)