Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
seivan committed Jul 4, 2014
2 parents fc27e31 + 806f3a6 commit db106b7
Show file tree
Hide file tree
Showing 16 changed files with 976 additions and 387 deletions.
45 changes: 26 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,47 @@
let myHeight = 34.5
let myWidth = 100.23
let sizeOfWindow = CGSize(width:myWidth, height:myHeight)
let myDouble:Double = sizeOfWindow.height // .height is a CGFloat
let isLargerThan = 213.3 > sizeOfWindow.width // 213.3 is a Double


//You can now compare or do mathematical operations on the following:
var doubleValue:Double = 5.0
var cgFloatValue:CGFloat = 5.0
var intValue:Int = 5
var int16Value:Int16 = 5
var int32Value:Int32 = 5
var int64Value:Int64 = 5
var uInt16Value:UInt16 = 5
var uInt32Value:UInt32 = 5
var uInt64Value:UInt64 = 5
````




### Overview

Adds math functions as properties and takes care of operators for interacting between different types of scalars.
Takes care of operators for interacting between different types of scalars.
This library makes it easier to compare to ```Int```, ```Float``` and ```CGFloat``` regardless of architecture.

This also makes implicit casts to Double or CGFloat for arguments or variables that takes either types.


``var myDouble = 2.0`` will give you a ```Double``` and you'd want to use that with other types.

Since ```CGFloat``` is not a ```Double``` on 32bit, it becomes hard to use CGGeomtry and frameworks like CoreGraphics or SpriteKit. This library makes it a little easier and hopefully Apple takes care of it soon.
Since ```CGFloat``` is not a ```Double``` on 32bit, it becomes hard to use CGGeometry and frameworks like CoreGraphics or SpriteKit. This library makes it a little easier and hopefully Apple takes care of it soon.

Works on both Mac OS and iOS.




### Math Functions
```swift
protocol ScalarFunctions {
var acos:Double {get}
var asin:Double {get}
var atan:Double {get}
func atan2(x:Double) -> Double
var cos:Double {get}
var sin:Double {get}
var tan:Double {get}
var exp:Double {get}
var exp2:Double {get}
var log:Double {get}
var log10:Double {get}
var log2:Double {get}
func pow(exponent:Double) -> Double
var sqrt:Double {get}
}

Many people disagreed with the global math functions being used as properties. I was on the fence on that one because I didn't want to write over them for 32 bit. However now that implicit casts are in place. This works on 32bit.
```swift
let yay = abs(2.0)
```


Expand Down
2 changes: 1 addition & 1 deletion ScalarArithmetic.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Pod::Spec.new do |s|
url = "https://github.com/seivan/#{name}"
git_url = "#{url}.git"
s.name = name
version = "1.0.0"
version = "1.1.0"
source_files = "#{name}/**/*.{swift}"

s.version = version
Expand Down
Loading

0 comments on commit db106b7

Please sign in to comment.