Taking the nearest decimals possible

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Taking the nearest decimals possible

GK19

Hi,
I have a query
i have 3 number
1] 1.6778
2] 2,032
How do i take the number 1.6778 to 1.7 (nearest value)
and 2.032 to 2.0?



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Taking the nearest decimals possible

Doug Stewart-4


On Wed, Apr 22, 2020 at 5:11 PM GK19 <[hidden email]> wrote:

Hi,
I have a query
i have 3 number
1] 1.6778
2] 2,032
How do i take the number 1.6778 to 1.7 (nearest value)
and 2.032 to 2.0?


One way (and there are many ways)
take your number and multiply by 10 
then take the integer part
then divide by 10

a=1.6778
b=(round(a*10))/10

--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: Taking the nearest decimals possible

GK19
Reply | Threaded
Open this post in threaded view
|

Re: Taking the nearest decimals possible

GK19
In reply to this post by GK19
So i have two values
A = 1.69 and B = 1.8
A = 2.1 and B = 2.4
How do i show it that they are approximately equal without using round
are there any relational operators that i can use?



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html