• 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
extracting the mantissa for a NSDecimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

extracting the mantissa for a NSDecimal


  • Subject: extracting the mantissa for a NSDecimal
  • From: Olivier <email@hidden>
  • Date: Tue, 29 Oct 2002 12:37:35 -0600

i'm trying to save an NSDecimal in a dictionary.

I study the NSDecimal structure and decided that all i really need to
save are:
_exponent, _isNegative and _mantissa field

i'm trying to get the mantissa field, i want to store it as a NSNumber
in my dictionary.

the length field of the NSDecimal tells how many short of the mantissa
are relevant

so i'm building my data this way:

NSMutableData *theNumberData = [NSMutableData
dataWithLength:16];
for (i = 0; i < valueOfObject._length; i++)
{
[theNumberData replaceBytesInRange: NSMakeRange(16 -
(i+1) * 2, 2)
withBytes:
&valueOfObject._mantissa[i]];

}

so that the relevant field are put in the data object starting from the
end of the object (most significant bytes first)

then start the problem, converting it to an NSNumber i tried:

const char *theNumberPtr = [theNumberData bytes];
[NSNumber numberWithUnsignedLongLong: *theNumberPtr]
[NSNumber numberWithUnsignedLongLong: theNumberPtr[0]]
[NSNumber numberWithUnsignedLongLong: &theNumberPtr]

without any success.

Any idea of how to get that mantissa in a NSNumber?

Olivier
_______________________________________________
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: Sheets, modal and non-modal
  • Next by Date: Re: modifying Info.plist at runtime
  • Previous by thread: Re: Problem with 10.2 after a clean active target
  • Next by thread: Re: What to use instead of EOF?
  • Index(es):
    • Date
    • Thread