aldweb

Close I. aldweb

Close II. PC Freeware

Close III. Palm Freeware

Close IV. Palm Shareware

Close V. iziBasic Palm

Close VI. Palm Knowledge

Close VII. Pocket Computer

Close VIII. miniPortail

Special !



Mobile version of
the aldweb Site

m.aldweb.com


Neither French, nor English?

Try one of these flags then:
[de] [es] [it] [pt]
Search




Weather / Spam / www

Lyon Weather


aldweb against spam


Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
298 Subscribers
Family's web sites

Webmaster - Infos
Friends News
Visits

   visitors

   visitors online

Poll
What do you think of the new design of the aldweb Site?
 
Great !
Beautiful
Average
So ugly...
Results
forum.gifForum - iziBasic - Topic #1613

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

active  Topic # 1613  Rounding up of numbers

03/05/2008 @ 22:31
by trent

Anonymous



Hello,
I am having a wonderful time programming my Zire 72 with iziBasic. I am gradually learning how to convert my Basic programs into iziBasic.
I just finnished a program for my job today and it works great, but I am having problems rounding up numbers. I have read the manual and it pretty much just says:
"Round v/n"
That doesn't help me much.
Here is an example line of my code that I need to round up.
%CPV%=%Hc%-%Lc%/10
The answer may come as 55.2 or 55.8 etc.
I need to round %CPV% up to the next whole number.
Can somebody please help me ?
Thanks in advance.
-trent-
  Post an answer  Top

[]   


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 1
--------
04/05/2008 @ 00:23
by nate Weil

Anonymous

visitor
v/n means variable/number just in case that's what you're asking. You would simply do Round %CPV% and it would round it up. You have something wrong with that line of code though... you can only have one operator per line of code doing math. So instead of
%CPV%=%Hc%-%Lc%/10
you have to do
%Lc%=%Lc%/10
%CPV%=%Hc%-%Lc%
Hope that helps!
Nate
Write to nate Weil   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 2
--------
04/05/2008 @ 04:05
by trent

Anonymous

visitor
Hi Nate,
The code compiles and runs the way I have it written. No problem there.
But I tried entering Round %CPV% on the following line and then I get a Syntax error for the Round %CPV% line.
Cheers,
Trent.
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 3
--------
04/05/2008 @ 11:12
by aldweb

Anonymous

visitor
Hello,

ROUND() is a function so it will just need parentheses to work:
%CPV%=%Hc%-%Lc%/10
%CPV%=ROUND(%CPV%)

ROUND() returns the closest integer, so ROUND(1.2) will return 1 and ROUND(1.7) will return 2. if you need 1.2 to return 2, you should modify your source code accordingly:
%CPV%=%Hc%-%Lc%/10+0.5
%CPV%=ROUND(%CPV%)

"you can only have one operator per line of code doing math."
Nate, please allow me to rectify this sentence. One operator is required in a function, so ROUND(%Hc%-%Lc%/10) does not work in iziBasic. BUT math assignations can have more parameters, so %CPV%=%Hc%-%Lc%/10 works fine.
Math assignations will work according to the PARSER compiling directive.
If PARSER is set to OFF (default value, a left over from the early version of iziBasic), the compiler will build the code this way:
%CPV%=(%Hc%-%Lc%)/10
If PARSER is set to ON, the compiler will build the code this way:
%CPV%=%Hc%-(%Lc%/10)

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 4
--------
04/05/2008 @ 14:51
by Nate Weil

Anonymous

visitor
ok sorry my bad. I didn't know IF-ENDIF is a function...
and just to be at least partly helpful :D functions always have to have a v=function() "structure". Then v equals whatever the function returns. And the easiest way, if you're reading the manual to tell what a function is is to look at its description and see if it says blah blah blah returns blah blah blah. The word return is the key. Thanks for correcting me aldweb :) and good luck trent!
Write to Nate Weil   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 5
--------
04/05/2008 @ 17:45
by aldweb

Anonymous

visitor
Nate, I didn't correct you, I would never do that. I just rectified one of your sentences, with the objective of helping you (and others).

IF/ENDIF is a statement, not a math assignment...
Nevertheless, this is maybe the main limitation of iziBasic that it requires to preprocess some calculations to be used in statements and functions. One would maybe want to do "IF A=ROUND(B*5.5) THEN..." instead of "C=B*5.5:C=ROUND(C):IF A=C THEN". The result is the same, it just requires a little bit of mental work to get accustomed to this specificity of iziBasic... This is something I have wanted to work on since ages, but I have always been enhancing iziBasic in other areas before...

And, this is a scoop, version 8.0 of iziBasic is on tracks, with a lot of new features: IR communications, Network communications, linking scrollbars and fields, 5WayNav, 320x480 HighRes+ mode, and many other goodies. I hope to release it by the end of May.

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 6
--------
04/05/2008 @ 17:54
by trent

Anonymous

visitor
Hello,
As usual you took care of the problem.
It works fine now.
Thanks so much !
Cheers,
-trent-
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n 7
--------
04/05/2008 @ 18:14
by Nate Weil

Anonymous

visitor
lol same dif whatever you want to call it thanks anyways :D
stop giving it away I'm excited enough as it is lol seriously I can not wait for june... though that's also cuz of the wwdc.
Write to Nate Weil   Post an answer  Top
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 



 
^ Top ^