Difference between revisions of "Talk:Floor"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Morerunes
(New page: ==Floor without OBSE?== While I personally think everyone should get OBSE, some people would rather not. I was trying to do the floor function without OBSE by setting and reading variable...)
 
imported>Qazaaq
(subtract 0.5, then cast to int)
Line 6: Line 6:


[[User:Morerunes|morerunes]] 15:50, 18 October 2008 (EDT)
[[User:Morerunes|morerunes]] 15:50, 18 October 2008 (EDT)
:According to [[:Category:Variables|this page]] all integer variables are rounded to the nearest integer. So 1.9 would be rounded to 2. Instead you want to round it to 1, so how about subtracting 0.5 before putting it into a short:
{{IndentPre|1|
short flooredInt
float decimalValue
set decimalValue to 1.9
set flooredInt to decimalValue - 0.5
;; rounding 1.4 to the nearest integer gives 1
set decimalValue to 2.0
set flooredInt to decimalValue - 0.5
;; rounding 1.5 to the nearest integer gives 2}}
:--[[User:Qazaaq|Qazaaq]] 17:26, 18 October 2008 (EDT)

Revision as of 16:26, 18 October 2008

Floor without OBSE?

While I personally think everyone should get OBSE, some people would rather not. I was trying to do the floor function without OBSE by setting and reading variables, but I can't think of a way to do it.

anybody have any ideas?

morerunes 15:50, 18 October 2008 (EDT)

According to this page all integer variables are rounded to the nearest integer. So 1.9 would be rounded to 2. Instead you want to round it to 1, so how about subtracting 0.5 before putting it into a short:
y0n1n2 short flooredInt float decimalValue set decimalValue to 1.9 set flooredInt to decimalValue - 0.5  ;; rounding 1.4 to the nearest integer gives 1 set decimalValue to 2.0 set flooredInt to decimalValue - 0.5  ;; rounding 1.5 to the nearest integer gives 2 n2n1y0
--Qazaaq 17:26, 18 October 2008 (EDT)