Copy an array of signed values in short, into an array of float. Sign extension is performed. - Java java.lang

Java examples for java.lang:int Array

Description

Copy an array of signed values in short, into an array of float. Sign extension is performed.

Demo Code


//package com.java2s;

public class Main {
    /**//from ww  w  . j  a  va2  s  .c  o  m
     * <p>Copy an array of signed values in short, into an array of float.</p>
     *
     * <p>Sign extension is performed.</p>
     *
     * @param   src   an array of short, whose values are interpreted as signed
     * @return      an array of float
     */
    static public float[] copySignedShortToFloatArray(short[] src) {
        if (src == null)
            return null;
        int n = src.length;
        float[] dst = new float[n];
        for (int j = 0; j < n; ++j) {
            dst[j] = src[j]; // allow sign extension
        }
        return dst;
    }
}

Related Tutorials