• Home
  • Troubleshoot
  • #Example
    • C
    • C++
    • Python
    • R-Programming
  • DSA
  • Quiz
  • Tutorial Videos
  • Home
  • Troubleshoot
  • #Example
    • C
    • C++
    • Python
    • R-Programming
  • DSA
  • Quiz
  • Tutorial Videos
  • #Deals
  • #News
  • #WiKi
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk

MyCodeTips mycodetips-newlogocopy1

  • Home
  • Troubleshoot
  • #Example
    • C
    • C++
    • Python
    • R-Programming
  • DSA
  • Quiz
  • Tutorial Videos
Tips&Tricks, Quick Tips, Swift

Data Types (int,char,bool) that looks cool.

Data Types, Since Swift, is a new programming language for iOS, macOS, watchOS, and tvOS app development. Swift provides its own versions of all fundamental C and Objective-C types, including Int for integers, Double and Float for floating-point values, Bool for Boolean values, and String for textual data.

Swift is a type-safe language, which means the language helps you to be clear about the types of values your code can work with. If part of your code requires a String, type safety prevents you from passing it an Int by mistake. Likewise, type safety prevents you from accidentally passing an optional String to a piece of code that requires a non-optional String.

Data Types

Int or UInt − This is used for whole numbers. More specifically, you can use Int32, Int64 to define 32 or 64 bit signed integers, whereas UInt32 or UInt64 to define 32 or 64-bit unsigned integer variables. For example, 42 and -23.

Float − This is used to represent a 32-bit floating-point number and numbers with smaller decimal points. For example, 3.14159, 0.1, and -273.158.

Double − This is used to represent a 64-bit floating-point number and used when floating-point values must be very large. For example, 3.14159, 0.1, and -273.158.

Bool − This represents a Boolean value that is either true or false.

String − This is an ordered collection of characters. For example, “Hello, World!”

Character − This is a single-character string literal. For example, “C”

Optional − This represents a variable that can hold either a value or no value.

Tuples − This is used to group multiple values in a single Compound Value.

Integer types

32-bit platform, Int is the same size as Int32.

64-bit platform, Int is the same size as Int64.

32-bit platform, UInt is the same size as UInt32.

64-bit platform, UInt is the same size as UInt64.

Int8, Int16, Int32, Int64 can be used to represent 8 Bit, 16 Bit, 32 Bit, and 64 Bit forms of a signed integer.

UInt8, UInt16, UInt32, and UInt64 can be used to represent 8 Bit, 16 Bit, 32 Bit and 64 Bit forms of unsigned integer.

Datatypes

Data TypesExampleDescription
Character“s”,”a”a 16-bit Unicode character
String“hello world!”represents textual data
Int3, -23an integer number
Float2.4, 3.14, -23.21represents 32-bit floating-point number
Double2.422342412represents 64-bit floating-point number
Booltrue and falseAny of two values: true or false

Integers

VariantSizeRange
Int88 bit-128 to 127
Int1616 bit-215 to 215-1
Int3232 bit-231 to 231-1
Int6464 bit-263 to 263-1
UIntDepends on platform0 to 232(32-bit platform) 0 to 264(64-bit platform)

Double to store the number with more precision (up to 15 decimal places)
Float to store the number with less precision (up to 6 decimal places)

Stay always with right Data types 🙂

  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 715 Views
Tags | swift, Tips & Tricks
AUTHOR
Ranjan

I m Ranjan and Sharing my years of experience in Software Development. Love to code in Mobile apps (IOS, Android, Power Apps, Xamarin, Flutter), Machine Learning ( Beginner ), Dot Net, Databases ( SQL Server, MySql, SQLite), WordPress, Cloud Computing ( AWS, Azure, Google, MongoDB) and many more as required on project-specific. Besides this love to travel and cook.

You Might Also Like

mycodetips Xcode

Tips for Bounds and Frames in IOS

December 23, 2013
mycodetips-newlogo2

Use Your MAC Without a Mouse-Part2

October 16, 2013
mycodetips-newlogo2

How to Use Your Computer Without a Mouse-Part-1

October 14, 2013
Next Post
Previous Post

Subscribe for updates

Join 6,915 other subscribers

whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

Latest Posts

  • YT-Featured-Algorithm
    What is Algorithm?
  • Frameworks of IOS
    Frameworks of IOS – Part ( I )
  • NSFileManager or NSPathUtilities
    NSFileManager or NSPathUtilities in Objective-C
  • Passing data between view controllers in Objective-C
    Passing data between view controllers in Objective-C
  • structures-classes-enum
    Structures and Classes in swift !
  • control-system-swift
    Control Flow in Swift
  • swift-concurrency-await
    Concurrency in Swift
  • time-complexity-dsa
    The Term Time Complexity in DSA
  • objective-c-datatypes1
    Objective-C Data Types
  • Convert-jpeg-word
    Convert JPG to Word – Tips You Should Try!

Quick Links

  • #about
  • #myapps
  • #contact
  • #privacy

Other Websites

  • #myQuestions
  • #myBhojanalaya
  • #gadgetFacts
  • #ifscCodesDB

Tag Cloud

Algorithm Android Android Studio API APP Programming Apps blogging Browser Config CSS DATABASE dsa ecommerce error Features Google IO HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Placeholder Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode

©mycodetips.com