Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static long MASK_4F = +0x7FFFFFFFFFFFFFFFl;
    public static long MASK_FF = +0xFFFFFFFFFFFFFFFFl;

    public static long save(long data, int start, int len, int value) throws Exception {
        if (start < 0 || len < 1 || start + len >= 64 || data < 0 || value < 0 || value > ((1 << len) - 1))
            throw new Exception("Invalid Param!");
        return ((value & (MASK_4F >> (63 - len))) << start)
                | (data & ((MASK_FF << (start + len)) | (MASK_4F >> (63 - start))));
    }
}