Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why does this line of code return 0?

Vetox Market
Vetox @ VSN & Ambat
Join date: 19 Nov 2006
Posts: 5
10-19-2009 00:21
I'm using something similar to this script to get the % of memory.

llOwnerSay((string)((llGetFreeMemory() / 64000) * 100));

But it returns 0.
I've worked out the issue is with the division. So why can't LSL divide a small value by a large value? Or am I missing something. Most languages can do this.
Even a simple calculator can do that.

I didn't think something this simple would be such a big of a problem. lol
What methods do most people use?
_____________________
VETOX
Design Innovation & Development

Vetox Org
VSN Simboarding
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
10-19-2009 00:49
It's not very intuitive but also not unique to LSL... try this:

llOwnerSay((string)((llGetFreeMemory() / 64000.0) * 100));

..basically you need to divide by a float, not an integer.
_____________________
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-19-2009 00:51
Because you're using integer literal values. If the free memory is smaller than 64000 (which is an incorrect value btw) the result of the division will always be smaller than 1. In integer calculation, this can only be 0.

Try this instead:

llOwnerSay((string)((llGetFreeMemory() * 100) / 65536));
Vetox Market
Vetox @ VSN & Ambat
Join date: 19 Nov 2006
Posts: 5
10-19-2009 00:52
(smacks forehead)
Time for some caffeine. I should have seen that.
_____________________
VETOX
Design Innovation & Development

Vetox Org
VSN Simboarding
Ee Maculate
Owner of Fourmile Castle
Join date: 11 Jan 2007
Posts: 919
10-19-2009 02:01
You tried to script without a cup of coffee? Are you crazy?
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
10-19-2009 02:18
most software is made of coffee and cigarettes:)
_____________________
From Studio Dora
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
10-19-2009 02:39
The development cycle:
Coffee
Cigarette
Code some lines
Test
Debug
Test
Cigarette
Coffee
Debug
Test
Repeat

So it's not just me then?
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
10-19-2009 05:20
From: Indeterminate Schism
The development cycle:
Coffee
Cigarette
Code some lines
Test
Debug
Test
Cigarette
Coffee
Debug
Test
Repeat

So it's not just me then?

Peers down the list... yup, that's the development cycle as I know it.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-19-2009 06:11
i don't smoke, and i rarely drink coffee as it messes with my stomach sometimes. perhaps that's why i can't focus on a single project lol
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
10-19-2009 07:00
Replace coffee with decaf, since I can't sleep if I drink it, and replace smokes with chocoloate, since I don't smoke. Otherwise, yeah, that's how it works.

But don't forget

staying up all night
answering pesky calls from people who say they love us but are interfering with concentration
managers or customers who keep bugging us for progress reports, when we're busy trying to make the *progress* in the first place
going to useless meetings

and of course, in the modern methodology:

google for API details or an algorithm -- so much better than a table full of open manuals and stopping by the engineering library for "Collected Algorithms of the ACM".
Starfire Desade
Can I play with YOUR mind
Join date: 10 Jul 2006
Posts: 404
10-19-2009 09:55
This cannot be the real coding cycle, as I don't see twinkies, jolt cola, or beer listed anywhere.
_____________________
"Hypnotic Magic" - Second Life's Hypnosis Specialists - Home of the TranceStar (Hypno, BDSM, Mind Control) Free your mind from the ordinary!

http://slurl.com/secondlife/Stellar%20Dreams/122/67/26/