|
Come up with a way to "multiply" without the asterisk symbol in Lua. My way:
print(1 / 0.5) >>2
When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played. |
|
|
|
what Lua version?
If you can use Lua 5.3(Or 5.2 I think you need to use a module for it)
You could use shifting. |
|
|
rvox u fail
When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played. |
|
|
I intended it to just be ROBLOX Lua.
When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played. |
|
|
I don't think ROBLOX Lua has bitwise operations? I don't know I haven't used ROBLOX in a month. |
|
|
Actually, rvox correctly multiplied 1 without the * . So... Seeing as how multiplication is simply stacking addition.
6+6+6+6 = 6*4
|
|
|
You may be able to accomplish this recursively. |
|
|
This is a multiplication thing I wrote with the Little Man Computer Instruction Set
(Doesn't handle negatives)
INP
STA Multiplicand
INP
STA Multiplier
RepeatedAddition LDA Multiplier
BRZ ProductFound
LDA CurrentSum
ADD Multiplicand
STA CurrentSum
LDA Multiplier
SUB One
STA Multiplier
BRA RepeatedAddition
ProductFound LDA CurrentSum
OUT
Multiplicand DAT 0
Multiplier DAT 0
CurrentSum DAT 0
One DAT 1
I'd probably apply something like this to Lua 5.1 |
|
|
|
|
fail because that uses loadstring which won't work on the client
When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played. |
|
|
I would just go with your way.
local function Multiply(A, B)
return A / (1/B) -- Or A/B^-1
end |
|
|
local x = 2
local y = 2
print(10^(math.log10(x) + math.log10(y))) >> 4
Done. |
|
NotwalJoin Date: 2014-12-31 Post Count: 915 |
Here's a wacky way:
local x = 4 -- the number of times your multiplying the number by
local y = 2 -- the number
local z -- the product
if y ~= 1 and x ~= 1 then
repeat
x = x - 1
z = z + y
until x == 0
else
z = 1
end
if x == 1 then
z = y
end
print(z) |
|
lordramboJoin Date: 2009-06-16 Post Count: 20628 |
There is no such thing as multiplying without multiplying. You're way is division, and will produce a division instruction in the bytecode. |
|
|
I said "multiply"
That implies sort-of multiply.
That implies simulating it.
That implies I AM NOT IN THE MOOD FOR YOUR GUYS BULLCRAP.
When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played. |
|
lordramboJoin Date: 2009-06-16 Post Count: 20628 |
You said "multiply".
That implies multiply.
You can't say someone else's solution is wrong (such as "1 + 1") when yours is exactly no better.
Also the solution is y/(1/x) |
|
chimmmihcJoin Date: 2014-07-24 Post Count: 2420 |
function m(n1, n2)
local sum
for i = 1, math.abs(n2) do
sum = sum + n1
end
if n1 < 0 or n2 < 0 then
sum = sum / -1
end
return sum
end |
|
|
@lord wins, one really simple line that does positives and negatives. |
|
|
[(a+a)/2]^N??????
it's technically not using multiplication :p.... |
|
|
Lol this is easy.
function multiply(a,b)
return a/(1/b)
end |
|
|
^
The Legend of Heroes Sen no Kiseki |
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
Multiplying without the asterisk? Useless - The amount of overhead for division of double precision floating point (And other numbers, at that) is much greater than that of multiplication. |
|
|
local function Multiply(A,B)
return A..string.char(42)..B
end
That might work lol |
|