Skip to content

Commit 11fa103

Browse files
committed
Fix: Book2: Listing 33, 34, 38: Change implicit casts to explicit ones (#692)
1 parent e41a169 commit 11fa103

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Change Log -- Ray Tracing in One Weekend
1212

1313
### _The Next Week_
1414
- Delete: remove unused u,v,w variables in initial `perlin::noise()` function (#684)
15-
15+
- Fix: Listing 33, 34, 38: Change implicit casts to explicit ones (#692)
1616

1717
----------------------------------------------------------------------------------------------------
1818
# v3.2.0 (2020-07-18)

books/RayTracingTheNextWeek.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,9 +1591,9 @@
15911591
auto v = p.y() - floor(p.y());
15921592
auto w = p.z() - floor(p.z());
15931593

1594-
int i = floor(p.x());
1595-
int j = floor(p.y());
1596-
int k = floor(p.z());
1594+
auto i = static_cast<int>(floor(p.x()));
1595+
auto j = static_cast<int>(floor(p.y()));
1596+
auto k = static_cast<int>(floor(p.z()));
15971597
double c[2][2][2];
15981598

15991599
for (int di=0; di < 2; di++)
@@ -1645,9 +1645,9 @@
16451645
w = w*w*(3-2*w);
16461646
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
16471647

1648-
int i = floor(p.x());
1649-
int j = floor(p.y());
1650-
int k = floor(p.z());
1648+
auto i = static_cast<int>(floor(p.x()));
1649+
auto j = static_cast<int>(floor(p.y()));
1650+
auto k = static_cast<int>(floor(p.z()));
16511651
...
16521652
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16531653
[Listing [perlin-smoothed]: <kbd>[perlin.h]</kbd> Perlin smoothed]
@@ -1780,9 +1780,9 @@
17801780
auto v = p.y() - floor(p.y());
17811781
auto w = p.z() - floor(p.z());
17821782
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1783-
int i = floor(p.x());
1784-
int j = floor(p.y());
1785-
int k = floor(p.z());
1783+
auto i = static_cast<int>(floor(p.x()));
1784+
auto j = static_cast<int>(floor(p.y()));
1785+
auto k = static_cast<int>(floor(p.z()));
17861786
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
17871787
vec3 c[2][2][2];
17881788
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++

0 commit comments

Comments
 (0)