Difference between revisions of "Talk:Differences from Previous Scripting"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Dragoonwraith
(→‎Auto-casting from Int to Float: strictly speaking, not always safe)
 
imported>Dragoonwraith
m (→‎Auto-casting from Int to Float: finishing my sentence)
 
Line 3: Line 3:
Just a note: technically, since both <tt>int</tt> and <tt>float</tt> are 32-bit numbers, and at least some of the <tt>float</tt>'s memory is dedicated to the exponent, <tt>int '''as''' float</tt> will not ''always'' work. This means the statement that "the compiler can automatically cast for you with no chance of error" with respect to "Int -> Float" is not strictly true.
Just a note: technically, since both <tt>int</tt> and <tt>float</tt> are 32-bit numbers, and at least some of the <tt>float</tt>'s memory is dedicated to the exponent, <tt>int '''as''' float</tt> will not ''always'' work. This means the statement that "the compiler can automatically cast for you with no chance of error" with respect to "Int -> Float" is not strictly true.


The likelihood of this coming up in a mod is rather slim, however. Presumably the <tt>float</tt> follows the IEEE standard and has a 23-bit mantissa; thus you would need an integer that uses 24 or more bits (i.e. <tt>>= 16,777,216</tt> or <tt><= -16,777,216</tt>).<br/>
The likelihood of this coming up in a mod is rather slim, however. Presumably the <tt>float</tt> follows the IEEE standard and has a 23-bit mantissa; thus you would need an integer that uses 24 or more bits (i.e. <tt>>= 16,777,216</tt> or <tt><= -16,777,216</tt>) to cause errors.<br/>
[[User:Dragoonwraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:Dragoonwraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 12:05, 22 January 2012 (EST)
[[User:Dragoonwraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:Dragoonwraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 12:05, 22 January 2012 (EST)

Latest revision as of 12:06, 22 January 2012

Auto-casting from Int to Float[edit source]

Just a note: technically, since both int and float are 32-bit numbers, and at least some of the float's memory is dedicated to the exponent, int as float will not always work. This means the statement that "the compiler can automatically cast for you with no chance of error" with respect to "Int -> Float" is not strictly true.

The likelihood of this coming up in a mod is rather slim, however. Presumably the float follows the IEEE standard and has a 23-bit mantissa; thus you would need an integer that uses 24 or more bits (i.e. >= 16,777,216 or <= -16,777,216) to cause errors.
Dragoon Wraith TALK 12:05, 22 January 2012 (EST)