Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Foreign Languages > Italian Forum
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Arrotondare un risultato

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-04-2008, 05:42 PM
Senior Member
 
Join Date: May 2008
Posts: 174
Default Arrotondare un risultato

Salve ragazzi,,
solitamente non mi sono mai preoccupato di dover inserire nei codici operazioni matematiche particolari perchè non si presentava mai la necessità ora però ho un piccolo quesito da porVi.
Come posso arrotondare un certo risultato a dei valori predefiniti e cioè a 0,5 a 2 a 5 a 10 ecc. ?
In pratica:
123,2 = 123,0 (arrotondamento a 0,5)
123,3 = 123,5 (arrotondamento a 0,5)
121 = 122 (arrotondamento a 2)
123 = 124 (arrotondamento a 2)
122 = 120 (arrotondamento a 5)
123 = 125 (arrotondamento a 5)
123 = 120 (arrotondamento a 10)
126 = 130 (arrotondamento a 10)
ecc.

C'è un modo rapido per ottenerlo?

Grazie mille
Reply With Quote
  #2 (permalink)  
Old 11-04-2008, 06:54 PM
giannimaione's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Naples, Italy
Posts: 244
Send a message via Skype™ to giannimaione
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Ciao Micro,
sara' questa giornata, sara' il vento di scirocco, ma non ho capito il tuo problema
Quote:
Originally Posted by micro View Post
In pratica:
123,2 = 123,0 (arrotondamento a 0,5)
123,3 = 123,5 (arrotondamento a 0,5)
121 = 122 (arrotondamento a 2)
123 = 124 (arrotondamento a 2)
122 = 120 (arrotondamento a 5)
123 = 125 (arrotondamento a 5)
123 = 120 (arrotondamento a 10)
126 = 130 (arrotondamento a 10)
cosa intendi per arrotondamento a 0,5 - 2 - 5 -10 ???
perche' 123,2 diventa 123,0 mentre 123,3 diventa 123,5 ??? (arr=0,5)
e poi:
(arr=5) 122=120 e 123=125 ????
ho capito solo che i valori arrotondati sono divisibili (non hanno resto) per l'arrotondamento, ma poi null'altro


un saluto,
__________________
Gianni
Reply With Quote
  #3 (permalink)  
Old 11-04-2008, 07:06 PM
Senior Member
 
Join Date: May 2008
Posts: 174
Default

ok ,
allora per arrotondamento a 0,5 significa che il risultato deve avere dei step a 0,5.
In pratica:
0,5
1,0
1,5
2,0 ecc.
Con arrotondamento a 10 avremo:
10
20
30 ecc.

Probabilmente ho usato impropriamente la parola arrotondamento, adesso spero di essere stato più chiaro
Reply With Quote
  #4 (permalink)  
Old 11-04-2008, 08:36 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

You should use the formula below:
Code:
<font size="2"><font face="Courier New"><font size="2"><font face="Courier New">RoundedValue=</font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Int</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(Value/RoundAt+</font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">0.5</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">)*RoundAt</font></font></font></font>
I joined a small program to test it.

Sorry for answering in english, but I don't speak italian.

Best regards
Attached Files
File Type: sbp Round.sbp (736 Bytes, 13 views)
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #5 (permalink)  
Old 11-05-2008, 07:32 AM
giannimaione's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Naples, Italy
Posts: 244
Send a message via Skype™ to giannimaione
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Ciao Micro,

Klaus mi ha preceduto

sì la formula è la seguente
Risultato=Int(Valore/FattorediArrotondamento+0.5)*FattorediArrotondamen to

quindi come vedi abbiamo trovato la stessa formula.

A presto,
__________________
Gianni
Reply With Quote
  #6 (permalink)  
Old 11-05-2008, 07:43 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Gianni,

The only difference between your formula and mine is that yours is in Italian and mine in English.
But fortunately, from the mathematical point of view those are the same .

Best regards.

Google traduzione

L'unica differenza tra la vostra e la mia formula è che il vostro è in italiano e in inglese miniera.
Ma per fortuna, dal matematico punto di vista quelli sono gli stessi .

Ciao.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #7 (permalink)  
Old 11-05-2008, 07:57 AM
giannimaione's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Naples, Italy
Posts: 244
Send a message via Skype™ to giannimaione
Awards Showcase
Beta Tester 
Total Awards: 1
Thumbs up +-*/

Hi Klaus,

you are right +-*/ is universal language
__________________
Gianni
Reply With Quote
  #8 (permalink)  
Old 11-05-2008, 04:31 PM
Senior Member
 
Join Date: May 2008
Posts: 174
Default

Grazie ad entrambi,
adesso che ho visto la formula mi si è rinfrescata la mente..... lo sapete che con l'età tutto tende a degradarsi (speriamo non tutto ....: ehehehe).

Bye
Reply With Quote
  #9 (permalink)  
Old 11-05-2008, 08:26 PM
giannimaione's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Naples, Italy
Posts: 244
Send a message via Skype™ to giannimaione
Awards Showcase
Beta Tester 
Total Awards: 1
Default nel blu dipinto di blu

non preoccuparti Micro, in fondo c'e' semre la pillola blu eheheheh
__________________
Gianni
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


All times are GMT. The time now is 12:06 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0