binToDec 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -55
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd7589ee2f37f6235a26c4b819399715d2149a5e
|
4
|
+
data.tar.gz: a0cddca7d6215cc9055091579de232394d92caa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 766213a9a8470ef7b567fde6c2f2c0a1f9e0a3e3b3cfcf4643fa95b9519e5d02edd7857c199bdb2d209cc5201cf82f67406d6a7439095346c564117f4cfff345
|
7
|
+
data.tar.gz: 7952295fbc0bdd2f9f40cd2e4b0a5e3bdbbe55b550e0bc0b5d9a5c28f043ee20c9c5d88f9a9ad9f5b17fb9ddc1a92cf9d994b82dad1fad68f6078202ad89e6b3
|
data/README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# Binary to Decimal Conversion (binToDec)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
binToDec is written in Ruby, and converts a binary number to a decimal only if
|
4
|
+
the argument is binary.
|
5
|
+
|
6
|
+
It should be considered an experimental gem.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
10
|
Add this line to your application's Gemfile:
|
10
11
|
|
11
|
-
gem '
|
12
|
+
gem 'binToDec'
|
12
13
|
|
13
14
|
And then execute:
|
14
15
|
|
@@ -16,70 +17,31 @@ And then execute:
|
|
16
17
|
|
17
18
|
Or install it yourself as:
|
18
19
|
|
19
|
-
$ gem install
|
20
|
-
|
21
|
-
Add the following HTML code to the page where you want the calculator to appear
|
22
|
-
|
23
|
-
**"<div id = "myCalculator">
|
24
|
-
<div id="panelDiv">
|
25
|
-
<input type ="text" id = "calcPanel" />
|
26
|
-
</div> <!--End panelDiv-->
|
27
|
-
</div><!--End myCalculator Div-->"**
|
28
|
-
|
29
|
-
|
30
|
-
Add the following to the bottom of application.html.erb (the script file must render in the body
|
31
|
-
section of the HTML page, not in the head section)
|
20
|
+
$ gem install binToDec
|
32
21
|
|
33
|
-
**<%= javascript_include_tag "jscalc.js" %>**
|
34
|
-
|
35
|
-
Add the following line to the head section of application.html.erb
|
36
|
-
|
37
|
-
**<%= stylesheet_link_tag "jscalc.css" %>**
|
38
|
-
|
39
|
-
**TO MAKE THE CALCULATOR DRAGGABLE**, ensure that jQuery-ui is installed or add the following files to the head section of application.html.erb BEFORE the stylesheet link tag.
|
40
|
-
|
41
|
-
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
|
42
|
-
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
|
43
22
|
## Usage
|
44
23
|
|
45
|
-
|
46
|
-
|
47
|
-
x = new Date()
|
24
|
+
Converter.binToDec(1000)
|
48
25
|
|
49
|
-
|
26
|
+
Converter.bintoDec(2)
|
50
27
|
|
51
|
-
|
28
|
+
## Basis
|
29
|
+
The program uses the following test to determine if the input is binary:
|
52
30
|
|
53
|
-
|
31
|
+
arg1.to\_s.split(//).map { |i| i.to\_i }.find\_all { |value| value > 0 }.inject(:*)
|
54
32
|
|
55
|
-
x.getFullYear() => 13
|
56
33
|
|
57
|
-
|
34
|
+
The program uses the following code to convert the input (arg1) to binary.
|
58
35
|
|
59
|
-
|
36
|
+
arg1.to\_s.split(//).map { |i| i.to\_i }.inject(0) { |accumulator, value| (accumulator + value) * 2 }
|
37
|
+
|
38
|
+
return result/2
|
60
39
|
|
61
|
-
x.getSeconds()
|
62
|
-
|
63
|
-
x.getMilliseconds();
|
64
|
-
|
65
|
-
Math.round();
|
66
|
-
|
67
|
-
navigator.appName
|
68
|
-
|
69
|
-
parseInt(1101,2)
|
70
|
-
|
71
|
-
isNaN(2)
|
72
|
-
|
73
|
-
typeof(2)
|
74
40
|
|
75
41
|
## Contributing
|
76
42
|
|
77
|
-
Written by Thomas Dowling (tomgdow)
|
43
|
+
Written by Thomas Dowling ([tomgdow](http://mathematica.stackexchange.com/users/106/tomd))
|
78
44
|
|
79
45
|
The National College of Ireland
|
80
46
|
|
81
47
|
thomasgdowling@gmail.com
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|