Giter Club home page Giter Club logo

Comments (23)

diegoparra avatar diegoparra commented on August 22, 2024

https://play.golang.org/p/Y3JVPXvtoXt

from aprendago.

andersoncleyson avatar andersoncleyson commented on August 22, 2024

https://play.golang.org/p/5ccToCkp0yH

from aprendago.

basquegran2 avatar basquegran2 commented on August 22, 2024

https://play.golang.org/p/6CTM6_6kj8z

from aprendago.

guifeliper avatar guifeliper commented on August 22, 2024
package main

import (
	"fmt"
)

const x = 10

func main() {
	fmt.Printf("decimal=%d, binario=%b, hexadecimal= %#x\n", x, x, x)

	y := x << 1
	fmt.Printf("decimal=%d, binario=%b, hexadecimal= %#x", y, y, y)
}

from aprendago.

Julian-ie avatar Julian-ie commented on August 22, 2024

https://play.golang.org/p/_fahIMXA_4h

from aprendago.

thiagoalgo avatar thiagoalgo commented on August 22, 2024

https://play.golang.org/p/DlCVj_fFON5

from aprendago.

viniciussanchez avatar viniciussanchez commented on August 22, 2024

https://play.golang.org/p/SJ5ImKiTdkF

from aprendago.

tomxdev avatar tomxdev commented on August 22, 2024
package main

import "fmt"

func main() {
	x := 150
	fmt.Printf("DECIMAL: %d\t BINARY: %b\t HEXADECIMAL: %#x\n", x, x, x)

	y := x >> 1
	fmt.Printf("DECIMAL: %d\t BINARY: %b\t HEXADECIMAL: %#x", y, y, y)
}

from aprendago.

an4kein avatar an4kein commented on August 22, 2024

https://play.golang.org/p/uQ5ffktkjjF

Achei interessante essa parada de deslocar bits, em um futuro nao muito distante posso utilizar isso para ofuscar um payload.

Em vez de escrever 600x2=1200 eu posso simplesmente usar o deslocamento de 1 bit para esquerda e chego no mesmo resultado de 1200 😈

from aprendago.

victorinno avatar victorinno commented on August 22, 2024

https://play.golang.org/p/mevPs8eHLtS

from aprendago.

ygorsimoes avatar ygorsimoes commented on August 22, 2024
package main

import "fmt"

func main() {
	numero := 10
	fmt.Printf("Decimal: %d\n", numero)
	fmt.Printf("Binário: %b\n", numero)
	fmt.Printf("Hexadecimal: %#x\n\n", numero)

	numeroComBitDeslocado := numero << 1
	fmt.Printf("Decimal: %d\n", numeroComBitDeslocado)
	fmt.Printf("Binário: %b\n", numeroComBitDeslocado)
	fmt.Printf("Hexadecimal: %#x", numeroComBitDeslocado)
}

Output:

Decimal: 10
Binário: 1010
Hexadecimal: 0xa

Decimal: 20
Binário: 10100
Hexadecimal: 0x14

from aprendago.

JPauloMoura avatar JPauloMoura commented on August 22, 2024
package main

/*
Crie um programa que:
- Atribua um valor int a uma variável
- Demonstre este valor em decimal, binário e hexadecimal
- Desloque os bits dessa variável 1 para a esquerda, e atribua o resultado a outra variável
- Demonstre esta outra variável em decimal, binário e hexadecimal
*/
import "fmt"

func main() {
	v := 60
	fmt.Printf("| %d | %b | %#x |\n\n", v, v, v)

	v2 := v << 1
	fmt.Printf("| %d | %b | %#x |", v2, v2, v2)
}

Resolução do Exercício

from aprendago.

Lucasmirandar avatar Lucasmirandar commented on August 22, 2024

https://play.golang.org/p/Z5VTuDLFo2B

from aprendago.

andersoncleyson avatar andersoncleyson commented on August 22, 2024
package main

import "fmt"

func main(){
	x := 20
	fmt.Printf("%d\t %b\t %#x\n", x, x, x)

	y := x << 1
	fmt.Printf("%d\t %b\t %#x\n", y, y, y)
}

from aprendago.

guilherme-de-marchi avatar guilherme-de-marchi commented on August 22, 2024
package main

import "fmt"

func main() {

	var param_1 int
	fmt.Print("Valor: ")
	fmt.Scan(&param_1)

	fmt.Printf("\nDecimal: %d | Hexadecimal: %x | Binario: %b\n", param_1, param_1, param_1)

	param_2 := param_1 << 1

	fmt.Printf("\nDecimal: %d | Hexadecimal: %x | Binario: %b\n", param_2, param_2, param_2)

}

Output:

Valor: 2

Decimal: 2 | Hexadecimal: 2 | Binario: 10

Decimal: 4 | Hexadecimal: 4 | Binario: 100

from aprendago.

ltbatis avatar ltbatis commented on August 22, 2024

https://play.golang.org/p/N18f47df_KF

from aprendago.

CarlosSMA avatar CarlosSMA commented on August 22, 2024
package main

import "fmt"

func main() {
	x := 10
	fmt.Println("-=-=-=-=-=-=-=-=- Variável 1 -=-=-=-=-=-=-=-=-")
	fmt.Printf("Binário - %b\nDecimal - %d\nHexadecimal - %#x\n\n", x, x, x)
	y := x << 1
	fmt.Println("-=-=-=-=-=-=-=-=- Variável 2 -=-=-=-=-=-=-=-=-")
	fmt.Printf("Binário - %b\nDecimal - %d\nHexadecimal - %#x\n", y, y, y)
}

Output

-=-=-=-=-=-=-=-=- Variável 1 -=-=-=-=-=-=-=-=-
Binário - 1010
Decimal - 10
Hexadecimal - 0xa

-=-=-=-=-=-=-=-=- Variável 2 -=-=-=-=-=-=-=-=-
Binário - 10100
Decimal - 20
Hexadecimal - 0x14

from aprendago.

AlissonAp avatar AlissonAp commented on August 22, 2024

https://go.dev/play/p/ix8s_LvE8L9

from aprendago.

CaueFarias avatar CaueFarias commented on August 22, 2024

https://go.dev/play/p/GmJqDJWeFbD

from aprendago.

Matheus-Natanael avatar Matheus-Natanael commented on August 22, 2024

package main

import (
"fmt"
)

var x int = 10

func main() {
fmt.Printf("Decimal x: %d\nBinário x: %b\nHexadecimal x: %#x\n",
x, x, x)

y := x >> 1
fmt.Printf("Decimal y: %d\nBinario y: %b\nHexadecimal y: %#x",
	y, y, y)

}

from aprendago.

gustavomfc avatar gustavomfc commented on August 22, 2024

package main

import "fmt"

func main() {
n := 42

fmt.Printf("%v em Decimal = %d\n", n, n)
fmt.Printf("%v em Binário = %b\n", n, n)
fmt.Printf("%v em Hexa = %x\n", n, n)

z := n << 1

fmt.Printf("%v em Decimal = %d\n", z, z)
fmt.Printf("%v em Binário = %b\n", z, z)
fmt.Printf("%v em Hexa = %x\n", z, z)

}

from aprendago.

M3L1M avatar M3L1M commented on August 22, 2024

var a int = 200

func main() {
fmt.Printf("%d\t%b\t%#x\n", a, a, a)

var b = a << 1
fmt.Printf("%d\t%b\t%#x\n", b, b, b)

}

from aprendago.

an4kein avatar an4kein commented on August 22, 2024
https://go.dev/play/p/EpgVukL9hPA

// You can edit this code!
// Click here and start typing.
package main

import "fmt"

var newNumber int

func main() {
	number := 200
	fmt.Printf("%v\n%#b\n%#x", number, number, number)
	newNumber = number << 1
	fmt.Println()
	fmt.Printf("%v\n%#b\n%#x", newNumber, newNumber, newNumber)
}

/*
- Crie um programa que:
    - Atribua um valor int a uma variável
    - Demonstre este valor em decimal, binário e hexadecimal
    - Desloque os bits dessa variável 1 para a esquerda, e atribua o resultado a outra variável
    - Demonstre esta outra variável em decimal, binário e hexadecimal
*/
---------------------------------------------------------------------------------------------------------------------------------------------
200
0b11001000
0xc8
400
0b110010000
0x190
Program exited.
---------------------------------------------------------------------------------------------------------------------------------------------

from aprendago.

Related Issues (20)

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.