请问在c 中怎样才能实现类似java里面的数据类型的问题?急急急!
package systeme.defaulttypes;
import java.math.BigInteger;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
public class IntNUM extends systeme.typclasses.NUM {
/** stores the int value */
private BigInteger biValue;
/** constructor for the class */
public IntNUM(int iVal) {
biValue = new BigInteger("" + iVal);
}
/** constructor for the class */
public IntNUM(String sVal) {
biValue=new BigInteger(sVal);
}
/** method to get the BigIntegrValue */
public BigInteger bigIntegerValue() {
return biValue;
}
// implementation of the class DATA
/////////////////////////////////////
/**
* method for getting the name of the type, returns "Int"
*/
public String getName() {
return "Int";
}
/**
* parses the element, uses BigInteger(String)
*/
public static IntNUM valueOf(String sVal) {
return new IntNUM(new BigInteger(sVal));
}
/**
* method for parsing the elements, implemenets DATAs sTyp is just for
* implementing the interface, is ignored
*/
public systeme.typclasses.DATA fromString(String sVal, String sTyp) {
return IntNUM.valueOf(sVal);
}
/**
* help function for Parsing reads a IntNUM from the Tokenizer
*/
public static IntNUM fromTokenizer(StringTokenizer ST) {
try {
if (!(ST.hasMoreTokens()))
throw new NumberFormatException("error in parsing Int: Int expected instead of <>");
String T1 = ST.nextToken().trim();
IntNUM iRet = valueOf(T1);
return iRet;
} catch (NoSuchElementException nse) {
throw new NumberFormatException("generation error: no tokens any more");
// should be unreachable
}
}
// implementation of the class EQ
/////////////////////////////////////
/** method for comparing two elements for equality */
public systeme.defaulttypes.BoolEQ eq(systeme.typclasses.EQ eqOther) {
if (eqOther instanceof systeme.defaulttypes.IntNUM)
return new systeme.defaulttypes.BoolEQ(bigIntegerValue().equals(((IntNUM) eqOther).bigIntegerValue()));
return systeme.defaulttypes.BoolEQ.FALSE;
}
/** method for comparing two elements for inequality */
public systeme.defaulttypes.BoolEQ neq(systeme.typclasses.EQ beqOther) {
return eq(beqOther).not();
}
// implementation of the class ORD
///////////////////////////////////
/** method for comparing two elements for < */
public systeme.defaulttypes.BoolEQ lt(systeme.typclasses.ORD eqOther) {
if (eqOther instanceof systeme.defaulttypes.IntNUM)
if (bigIntegerValue().compareTo(((IntNUM) eqOther).bigIntegerValue()) == -1)
return systeme.defaulttypes.BoolEQ.TRUE;
return systeme.defaulttypes.BoolEQ.FALSE;
}
// "implementation" of the class NUM
// work directly on the BigIntegers (NUM does string conversion)
/////////////////////////////////////////////////////////////////
/** add an element */
public systeme.typclasses.NUM add(systeme.typclasses.NUM nmOther) {
if (nmOther instanceof systeme.defaulttypes.IntNUM) {
return new IntNUM(bigIntegerValue().add(((systeme.defaulttypes.IntNUM) nmOther).bigIntegerValue()));
}
return super.add(nmOther);
}
/** subtract an element */
public systeme.typclasses.NUM sub(systeme.typclasses.NUM nmOther) {
if (nmOther instanceof systeme.defaulttypes.IntNUM) {
return new systeme.defaulttypes.IntNUM(bigIntegerValue().subtract(((systeme.defaulttypes.IntNUM) nmOther).bigIntegerValue()));
}
return super.sub(nmOther);
}
/** multiply an element */
public systeme.typclasses.NUM mult(systeme.typclasses.NUM nmOther) {
if (nmOther instanceof IntNUM) {
return new IntNUM(bigIntegerValue().multiply(((IntNUM) nmOther).bigIntegerValue()));
}
return super.mult(nmOther);
}
/** divide an element */
public systeme.typclasses.NUM divide(systeme.typclasses.NUM nmOther) {
if (nmOther instanceof systeme.defaulttypes.IntNUM) {
return new systeme.defaulttypes.IntNUM(bigIntegerValue().divide(((systeme.defaulttypes.IntNUM) nmOther).bigIntegerValue()));
}
return super.divide(nmOther);
}
}
请问在c里面类似的类型以及里面方法该如何实现?
多谢!
相关推荐
基于simulink的调制器仿真设计与fpga实现 (1)调频或调幅时的载波频率为1-2MHz可调,且能通过按键自由调整 (2)可选择内部的调制信号或外部输入的调制信号进行调制,内部产生的调制信
基于simulink的调制器仿真设计与fpga实现 (1)调频或调幅时的载波频率为1-2MHz可调,且能通过按键自由调整。 (2)可选择内部的调制信号或外部输入的调制信号进行调制,内部产生的调制信号频率在100Hz-10KHz间连续可调。 (3)内部产生的100Hz-10KHz调制信号可以为正弦波、三角波、方波、锯齿波,并且可向外输出。 用MATLAB DSP Builder、VHDL语言来设计
基于Simulink的调制器仿真设计与FPGA实现:载波频率可调,内外调制信号选择多样,内部信号频率连续可调且波形多样,基于Simulink的调制器仿真设计及FPGA实现:灵活调整载波频率与调制信号类
基于Simulink的调制器仿真设计与FPGA实现:载波频率可调,内外调制信号选择多样,内部信号频率连续可调且波形多样,基于Simulink的调制器仿真设计及FPGA实现:灵活调整载波频率与调制信号类型,支持内外调制源切换与输出控制,基于simulink的调制器仿真设计与fpga实现 (1)调频或调幅时的载波频率为1-2MHz可调,且能通过按键自由调整。 (2)可选择内部的调制信号或外部输入的调制信号进行调制,内部产生的调制信号频率在100Hz-10KHz间连续可调。 (3)内部产生的100Hz-10KHz调制信号可以为正弦波、三角波、方波、锯齿波,并且可向外输出。 用MATLAB DSP Builder、VHDL语言来设计 ,基于simulink的调制器仿真设计; FPGA实现; 载波频率调整; 调制信号选择; 内部调制信号类型输出。,基于Simulink的调制器仿真设计:可调载波频率与多波形调制FPGA实现
STM32入门核心解析:从GPIO到时钟树的嵌入式底层实践
微控制器是嵌入式系统的核心执行单元,其本质是面向实时控制的专用计算平台。理解其工作原理需从硬件抽象层切入:ARM Cortex-M内核提供确定性指令执行能力,而GPIO配置、时钟树管理、中断优先级设定共同构成系统可控性的三大基石。其中,GPIO的8种工作模式直指电气接口设计本质,时钟树配置决定外设功能是否真正使能——二者缺一不可。技术价值在于构建可预测、可调试、可复现的硬件控制链路,广泛应用于智能车、工业传感器节点、教学实验平台等对实时性与稳定性要求严苛的场景。本文聚焦STM32F103系列,以标准外设库和
STM32硬件兼容方案MH32 F103 A单片机深度解析
嵌入式系统中,硬件兼容性设计是提升工程效率的关键技术。通过引脚级兼容和架构优化,MH32 F103 A单片机实现了与STM32的全方位兼容,同时将主频提升至216MHz。这种兼容方案不仅保留了原有STM32的软件生态,还显著提升了计算性能,特别适合需要高性能且低迁移成本的场景,如工业控制、无人机电调和数字电源等。实测数据显示,MH32的GPIO翻转速度比STM32快1.8倍,CoreMark测试性能提升近3倍,为嵌入式开发者提供了一种无缝升级路径。
从零到一:用TouchGFX与STM32CubeMX构建你的第一个嵌入式GUI应用
本文详细介绍了如何使用TouchGFX与STM32CubeMX从零开始构建嵌入式GUI应用,涵盖开发环境搭建、正点原子阿波罗V2开发板硬件解析、STM32F429IGT6配置、界面设计及多任务管理。通过实战案例演示多IO控制系统开发,帮助开发者快速掌握嵌入式GUI开发核心技术,提升产品交互体验。


