Giter Site home page Giter Site logo

go-to64's Introduction

go-to64

About

go-to64 analyzes Golang main package to convert int/uint to int64/uint64. This is an experiment tool, so be very careful.

In a 32-bit environment such as CodeForces, this tool may be useful if you want to force the source code of main package to always use 64-bit integers.

Installation

go install github.com/ttakezawa/go-to64@latest

Usage

go-to64 -fix .

Experimental result

This tool will replace type and cast integer literal to int64 or uint64 as shown in the following example.

Before:

package main

import (
	"fmt"
	"math/bits"
)

const (
	A, B int  = 1, 2
	C    uint = 3
	D         = 4
	E         = 5 + int(C)
)

var (
	a, b int  = 1, 2
	c    uint = 3
	d         = 4
	e         = 5 + add(6+a, int(c))

	slice []int = []int{3, 1}

	dp [999]int
)

func main() {
	s := 15
	s = bits.OnesCount(uint(s))
	for i := 0; i < add(a, b); i++ {
		fmt.Println(i + 100 + add(a, b))
	}
}

func add(a, b int) int {
	return a + b
}

After:

package main

import (
	"fmt"
	"math/bits"
)

const (
	A, B int64  = 1, 2
	C    uint64 = 3
	D           = 4
	E           = 5 + int64(C)
)

var (
	a, b int64  = 1, 2
	c    uint64 = 3
	d           = int64(4)
	e           = int64(5) + add(int64(6)+a, int64(c))

	slice []int64 = []int64{3, 1}

	dp [999]int64
)

func main() {
	s := int64(15)
	s = int64(bits.OnesCount64(uint64(s)))
	for i := int64(0); i < add(a, b); i++ {
		fmt.Println(i + int64(100) + add(a, b))
	}
}

func add(a, b int64) int64 {
	return a + b
}

go-to64's People

Contributors

ttakezawa avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.