Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a file that aids in String and Int Conversions #948

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Create README.md
TheNova22 authored Sep 30, 2020
commit 876286c9f931dc8627029e4e8bcaebbbafd09ce5
39 changes: 39 additions & 0 deletions StringAndIntOps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# String And Int Operations
The importance of various number like binary numbers, hexadecimals, ASCII values are well known.

Hence, this file aims to simply and aid in the process of conversion to required result within a tap of few buttons by the help of extensions.

## Binary Numbers
A base-2 numerical system where an integer is defined using only 1's and 0's
Example : 13 in binary is 1101

## Hexadecimal Numbers
A system of representation of numbers where the radix present is 16 i.e. the numbers used in this system range from 0...9 & A,B,C,D,E,F.
Example : 10 in hexadecimal is a

## ASCII
A method adapted that represents characters as numbers
Example : 'a'(lowercase) in terms of ASCII code is 97

## Implementation
```swift
let value = "10".intToHex // returns "10" as Hexadecimal
print(value) // prints "a"
```

```swift
let value = "A".ascii // returns "A" as Ascii value
print(value) // prints 65
```

```swift
let value = 13.binString // returns 13 as Binary String
print(value) // prints "1101"
```

```swift
let value = 97.intToAscii // returns 97 as a character taking in the integer as ASCII value
print(value) // prints "a"
```

*Written for Swift Algorithm Club by Jayant Sogikar*