iPhone-处理复数 [英] iPhone -- working with complex numbers

查看:102
本文介绍了iPhone-处理复数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出将复数放入面向数学的iPhone应用程序的最佳方法。我找到了有关复杂数字的mac osx手册页,看起来是一个合理的开始。三个问题:

I'm trying to figure out the best way to put complex numbers into my math-oriented iPhone app. I've found the mac osx manual page for complex numbers, which looks like a reasonable start. Three questions:

(1)这是最好的起点吗?

(2)我将需要一个面向对象的包装器-NSValue是否可以这样做吗?还是我应该自己写? (这并不困难,但是如果存在,我宁愿使用内置的)。

(3)是否有内置的方法来获取复合物的字符串表示形式?

(1) Is this the best starting point?
(2) I will need an object-oriented wrapper -- can NSValue do this somehow? Or should I just write my own? (not difficult, but I'd rather use a built-in one if it exists).
(3) Is there a built-in way to get a string representation of a complex?

推荐答案


  1. 似乎合理。

  2. 我只是创建您自己的类,具有复杂的ivar。可能可以将NSNumber子类化(从而使NSValue子类化)来做一些理智的事情,但是您必须小心一点。

  3. 不,只需获取实部和虚部并打印那些。

这篇关于iPhone-处理复数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆