The protocol buffer does not have a native decimal type-for all types, see http://code.google.com/apis/protocolbuffers/docs/proto.html#scalar. Instead, I did it (which is obviously incorrect now) Suppose, floating-point numbers can replace decimals. It doesn’t because there is a rounding problem.
Cocoa has a set of C functions in NSDecimal.h, and they look very attractive. However, since I am working with a .NET writes the code for the server to communicate, so I need a way to convert to a format that both systems can understand.
I assume I will use the original “byte” type in both systems Transfer data between and convert to native decimal type in each environment: NSDecimal on the Cocoa side, Decimal on the .NET side. Here, I don’t know how to proceed.
What intermediate format should I use – Binary-encoded decimals seem to be a possibility, but I have to implement an algorithm to convert the two systems by myself.
Is there a byte-encoded decimal format, both .NET and Cocoa say I can use ?
Thank you very much.
I I have been using an iOS app written with CocoaTouch to use Protocol Buffers, and encountered a novice error that may be equivalent to a decimal number.
The protocol buffer does not have a native decimal type – for all types , See http://code.google.com/apis/protocolbuffers/docs/proto.html#scalar. Instead, I made the (obviously incorrect now) assumption that floating-point numbers can replace decimals. It doesn’t because There is a rounding problem.
Cocoa has a set of C functions in NSDecimal.h, and they look attractive. However, since I am communicating with a server that writes code in .NET, I need A way to convert to a format that both systems can understand.
I assume I will use the original “byte” type to transfer data between the two systems, and convert in each environment Native decimal type: NSDecimal on the Cocoa side, Decimal on the .NET side. Here, I am not sure how to proceed.
What intermediate format should I use-binary-coded decimals seems to be a possibility, but I have to implement an algorithm to convert the two systems by myself.
Is there a byte-encoded decimal format that both .NET and Cocoa say I can use it?
Thank you very much.
I randomly hacked a rather random protobuf-net format, which maps to the .NET decimal type – The layout is here. This is for .NET-to-.NET, but I don’t know much about Cocoa decimals.