Lessons
Go Introduction
Go Get Started
Go Syntax
Go Comments
Go Variables
- Declare Variables
- Go में Variables का परिचय
- Go में Multiple Variable Declaration
- Variable Naming Rules (नामकरण के नियम)
Go Constants
Go Output
Go Data Types
- Basic Data Types
- Go Boolean Data Type (बूलियन डेटा प्रकार)
- Go Integer Data Types
- Go Float Data Types
- Go String Data Type
Go Arrays
Go Slices
Go Operators
- Go Operators
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Bitwise Operators
Go Conditions
Go Switch
Go Loops
Go Functions
Go Struct
Go Maps
Project Structure
Go Integer Data Types
Go Integer Data Types (पूर्णांक डेटा प्रकार)
Integer डेटा प्रकार का उपयोग केवल पूर्णांक (whole numbers) संग्रहीत करने के लिए किया जाता है, जैसे 35, -50 या 1345000।
Integer डेटा प्रकार की दो श्रेणियाँ हैं:
- Signed integers - सकारात्मक और नकारात्मक दोनों मान रख सकते हैं।
- Unsigned integers - केवल गैर-ऋणात्मक मान रख सकते हैं।
int है। यदि आप type specify नहीं करते हैं तो यह int होगा।
Signed Integers (साइन किए गए पूर्णांक)
Signed integers, int keywords के साथ घोषित किए जाते हैं और ये दोनों positive और negative मान रख सकते हैं।
उदाहरण (Example)
package main
import ("fmt")
func main() {
var x int = 500
var y int = -4500
fmt.Printf("Type: %T, value: %v\n", x, x)
fmt.Printf("Type: %T, value: %v\n", y, y)
}
Go में signed integers के पाँच प्रकार हैं:
| Type | Size | Range |
|---|---|---|
| int | Platform dependent (32-bit या 64-bit) | -2147483648 to 2147483647 (32-bit) -9223372036854775808 to 9223372036854775807 (64-bit) |
| int8 | 8 bits/1 byte | -128 to 127 |
| int16 | 16 bits/2 byte | -32768 to 32767 |
| int32 | 32 bits/4 byte | -2147483648 to 2147483647 |
| int64 | 64 bits/8 byte | -9223372036854775808 to 9223372036854775807 |
Unsigned Integers (असाइन किए गए पूर्णांक)
Unsigned integers, uint keywords के साथ घोषित किए जाते हैं और केवल non-negative मान रख सकते हैं।
उदाहरण (Example)
package main
import ("fmt")
func main() {
var x uint = 500
var y uint = 4500
fmt.Printf("Type: %T, value: %v\n", x, x)
fmt.Printf("Type: %T, value: %v\n", y, y)
}
Go में unsigned integers के पाँच प्रकार हैं:
| Type | Size | Range |
|---|---|---|
| uint | Platform dependent (32-bit या 64-bit) | 0 to 4294967295 (32-bit) 0 to 18446744073709551615 (64-bit) |
| uint8 | 8 bits/1 byte | 0 to 255 |
| uint16 | 16 bits/2 byte | 0 to 65535 |
| uint32 | 32 bits/4 byte | 0 to 4294967295 |
| uint64 | 64 bits/8 byte | 0 to 18446744073709551615 |
गलत उदाहरण (Error Example)
package main
import ("fmt")
func main() {
var x int8 = 1000
fmt.Printf("Type: %T, value: %v", x, x)
}