From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error in calculation


@crossrulz wrote:
 All of those are way better than your stupid CLD shirt.Smiley Tongue

Jeff, you may need this.

Message 11 of 22
(1,755 Views)

Can't follow you lol

0 Kudos
Message 12 of 22
(1,733 Views)

@feriel0209 wrote:

Can't follow you lol


Someone just got burned.

0 Kudos
Message 13 of 22
(1,730 Views)

There's a lot of good stuff there. This reminded me that I've had this VI sitting on my hard drive since forever, which takes a slightly different short-circuit approach. The performance looks promising, but I haven't done a whole lot of benchmarking or testing, and haven't actually used it in production code.

 

The basic idea is to leverage the equality operator to get the Inf/NaN/-0 behaviors, and short-circuit whenever the two quantities are equal. Then check that the exponents differ by no more than one and bail if not. Finally, compute the ULP threshold from the exponent and do the comparison. Other tunings may work better, depending on what your data looks like.

 

FloatEqualityToUlpThreshold.png

 

One caveat is that it doesn't allow any tolerance when comparing to zero. That could be handled with some extra logic if desired, but since that situation is ambiguous it might be better handled externally anyway. Let me know what other situations I missed.

0 Kudos
Message 14 of 22
(1,718 Views)

@JLewis wrote:

There's a lot of good stuff there. This reminded me that I've had this VI sitting on my hard drive since forever,


Interesting implementation, but I feel the version Altenbach did here probably is faster since it doesn't deal with any floating point math.

0 Kudos
Message 15 of 22
(1,706 Views)

Floating-point math itself isn't all that slow--the problem is avoiding the one super-slow operation that dominates. In the other VI, it's the Type Cast (counterintuitive, I know). In my case, I suspected the Mantissa/Exponent primitive. Some very quick and dirty benchmarks showed about a 4x improvement for the full path (and more for the short-circuit cases).

 

Jim

0 Kudos
Message 16 of 22
(1,698 Views)

@Hooovahh wrote:

@crossrulz wrote:
 All of those are way better than your stupid CLD shirt.Smiley Tongue

Jeff, you may need this.


Warning OT RE: Who needs a link like that?  Trust me! crossrulz has had better clothing supplied than what he admits too!  But, I hope he does not wear them on the weekends!  If he really wanted to dress nice:

Burn.PNG

He would have a nice shirt!

 

Now if I could get a "Hoodie"...I'd be dressed well all week


"Should be" isn't "Is" -Jay
0 Kudos
Message 17 of 22
(1,678 Views)

Jeff·Þ·Bohrer wrote: Trust me! crossrulz has had better clothing supplied than what he admits too!

Let's just say there is a reason my then newborn put a giant pee stain on itSmiley Wink


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 18 of 22
(1,666 Views)

18998_1036237526450309_795570471866468565_n.jpg

Message 19 of 22
(1,627 Views)

Just my 2 cents,

 

floating point in labview

 

sorry, in french  >  take a look a the attached VI  (ouadji_float.vi)

0 Kudos
Message 20 of 22
(1,612 Views)