• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Floating point problem???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Floating point problem???


  • Subject: Floating point problem???
  • From: "Mike Dean" <email@hidden>
  • Date: Mon, 03 Feb 2003 19:03:14 -0700

I am writing and debugging a physiological simulation and have encountered a strange "off by ten" error.

Extremely bizarre problem. Involves calculation of fitness adjusted cardiac output per iteration, which calculates out 10 times smaller than it should - this drives tissue po2 into the toilet, which is how I located the error. But you don't need to know the physiology to see the problem:

The interesting problem is that the debugger indicates everything is in order but it does not work.
The code is here:

[myHeart setDecilitersPerIteration:[myHeart effectiveCardiacOutput]*c17];
****[myHeart setFitnessAdjustedOutputPerIteration:([myHeart decilitersPerIteration]*(1 - c69*[myHeart effectiveCardiacOutput]))];


(gdb) p c69
$1 = 0.0027999999
(gdb) p 1- c69* myHeart.effectiveCardiacOutput
$2 = 0.98612993270738558
(gdb) p myHeart.decilitersPerIteration*0.98612
$3 = 0.81413999432086948
(gdb)

However, fitnessAdjustedOutputPerIteration now has a value of 0.0814148188 which is off by ten. The debugger information also shows the correct value for decilitersPerIteration (0.825599313).

Just to make sure, I retyped the expression directly as follows and again it is off by 10.

(gdb) p myHeart.decilitersPerIteration*(1 - c69*myHeart.effectiveCardiacOutput)
$1 = 0.81414819475726108
(gdb) p myHeart.fitnessAdjustedOutputPerIteration
$2 = 0.0814148188
(gdb)

When I simply patch this by multiplying the value by 10, then my simulation actually starts to behave correctly. However, I do not want to do this - the above output suggests there may be a Cocoa problem and I worry about moving forward without understanding what is going on here.

Any help will be appreciated. Greatly.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: NSLayoutManager question
  • Next by Date: IB palettes and [NSBezierPath setDefaultLineWidth:]
  • Previous by thread: Searching PATH environment var for executables prior to NSTask invocation
  • Next by thread: IB palettes and [NSBezierPath setDefaultLineWidth:]
  • Index(es):
    • Date
    • Thread