help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set value to a custom significance. (no display)


From: Judd Storrs
Subject: Re: Set value to a custom significance. (no display)
Date: Mon, 1 Mar 2010 12:48:49 -0500

First of all, the machine native floating point is base 2, not base 10
so this is going to be an approximation. However, something like this
may work by removing the remainder at each step:

octave:1> format long
octave:2> a = 0.499/2
a =  0.249500000000000
octave:3> a = round(100*a)/100
a =  0.250000000000000
octave:3> b = a * 2
b =  0.500000000000000
octave:4> b = round(100*b)/100
b =  0.500000000000000

You could use round, ceil or floor depending on how you want rounding to work.


--judd


reply via email to

[Prev in Thread] Current Thread [Next in Thread]