كود آلة حاسبة متقدمة

2 مشترك

اذهب الى الأسفل

ãÚáæãÉ كود آلة حاسبة متقدمة

مُساهمة من طرف mama1 الخميس 23 سبتمبر 2010 - 23:09

<SCRIPT LANGUAGE="javascript">


var computed = false;
var memory = 0;
var bin = 0;

function addChar(input, character)
{
if (computed) reset();
if (input.value == null || input.value == '0') input.value = character;
else
{
input.value += character;
computed = false;
}
}

function reset()
{
document.f.display.value=0;
document.f.stack.value=0;
computed = false;
}

function swipe()
{
document.f.stack.value=0;
computed=true;
}

function wipe()
{
document.f.display.value='';
computed=false;
}

function newSlate()
{
reset();
memory=0;
bin=0;
}

function deleteChar(input)
{
input.value = input.value.substring(0, input.value.length - 1);
computed = false;
}

function changeSign(input)
{
if(input.value.substring(0, 1) == '-')
input.value = input.value.substring(1, input.value.length);
else
input.value = '-' + input.value;
computed = false;
}

function testFirst()
{
var a = (document.f.stack.value.substring(0,1));
if (a == '-' || a == '.' || a == '0' || a== '1' || a == '2' || a =='3' || a == '4' || a == '5' || a == '6' || a == '7' || a == '8' || a == '9')
testLast()
else
alert('Error...

Enter Number First!');
computed = true;
}

function testLast()
{
var b = (document.f.stack.value.substring(document.f.stack.value.length,document.f.stack.value.length-1))
if (b == '0' || b == '1' || b == '2' || b =='3' || b == '4' || b == '5' || b == '6' || b == '7' || b == '8' || b == '9')
goOperation()
else
alert('Error...

Entry Incomplete!');
computed = true;
}

function goOperation()
{
document.f.display.value=eval(document.f.stack.value) * 100.00 /100.00;
computed = true;
}

function cos()
{
document.f.display.value=Math.cos(document.f.display.value);
swipe();
computed=true;
}

function acos()
{
document.f.display.value=Math.acos(document.f.display.value);
swipe();
computed=true;
}

function sin()
{
document.f.display.value=Math.sin(document.f.display.value);
swipe();
computed=true;
}

function asin()
{
document.f.display.value=Math.asin(document.f.display.value);
swipe();
computed=true;
}

function tan()
{
document.f.display.value=Math.tan(document.f.display.value);
swipe();
computed=true;
}

function atan()
{
document.f.display.value=Math.atan(document.f.display.value);
swipe();
computed=true;
}

function log()
{
document.f.display.value=Math.log(document.f.display.value);
swipe();
computed=true;
}

function exp()
{
document.f.display.value=Math.exp(document.f.display.value);
swipe();
computed=true;
}

function sqrt()
{
document.f.display.value=Math.sqrt(document.f.display.value);
swipe();
computed=true;
}

function abs()
{
document.f.display.value=Math.abs(document.f.display.value);
swipe();
computed=true;
}

function square()
{
document.f.display.value=Math.pow((document.f.display.value), 2);
swipe();
computed=true;
}

function cube()
{
document.f.display.value=Math.pow((document.f.display.value), 3);
swipe();
computed=true;
}

function perCent()
{
addChar(document.f.stack,'/100');
wipe();
computed=false;
}

function round()
{
document.f.display.value=Math.round(document.f.display.value);
swipe(this.form);
computed=true;
}

random.m=714025; random.a=4096; random.c=150889;
random.seed= (new Date()).getTime()%random.m;

function random()
{
random.seed = (random.seed*random.a + random.c) % random.m;
mikesnum=(random.seed/random.m);
computed=true;
}

function mem(c)
{
if (c == 1)
{
memory =(document.f.display.value * 1);
document.f.display.value='';
swipe(this.form);
computed = false;
}

if (c == -1)
{
document.f.display.value = memory ;
document.f.stack.value = document.f.display.value;
computed = false;
}

if (c == 0)
{
document.f.display.value = 0;
document.f.stack.value=0; memory = 0;
computed = false;
}

if (c == 2)
{
bin = (document.f.display.value * 1);
document.f.display.value='';
swipe(this.form);
computed = false;
}

if (c == -2)
{
document.f.display.value = bin ;
document.f.stack.value = document.f.display.value; bin = 0;
computed = false;
}

if (c == 3)
{
document.f.display.value = 0;
document.f.stack.value=0;
bin = 0;
computed = false;
}
}

function onlyTwo()
{
document.f.display.value=(document.f.display.value * 100);
document.f.display.value=Math.round(document.f.display.value)/100;
swipe();
computed=true;
}

function helpFile()
{
var content="KEY FEATURES

"+
"< - > Rounds up or down to nearest integer
"+
"<00> Rounds up or down to 2 decimal places
"+
"Num Generates psuedo-random non-cryptograhic number
"+
"M+ Adds single entry only to memory bin no.1
"+
"MR Recalls stored single item from memory bin no.1
"+
"MC Clears item from memory bin no.1
"+
"M2+ Adds single entry only to memory bin no.2
"+
"M2R Recalls single item from memory bin no.2
"+
"M2C Clears item from memory bin no.2
"+
"C Clears all, except memory no.1 and memory no.2
"+
"Clear Resets all features to zero
"+
"+- Inverts value positive/negative of current display value
"+
"<- Deletes last digit of current display
"+
"X2 Returns value of current display to power 2
"+
"X3 Returns value of current display to power 3
"+
"% Divides entry by 100 to return per centage
"+
"Sqrt Returns the square root of display value

"+
"E1/2 Pi Ln2 Ln10 Return Mathematic constants

"+
"Log Abs Atan Tan
"+
"Acos Cos Asin Sin Return Math calculation of display value:"

alert(content);
}


//-- END -->

</SCRIPT>
mama1
mama1
 
 

ذكر
عدد المساهمات : 766
معدل النشاط : 5896
السُمعة : 0

http://www.ahla9orane.mam9.com

الرجوع الى أعلى الصفحة اذهب الى الأسفل

ãÚáæãÉ رد: كود آلة حاسبة متقدمة

مُساهمة من طرف s@kr الجمعة 24 سبتمبر 2010 - 0:44

avatar
s@kr
 
 

ذكر
عدد المساهمات : 22599
معدل النشاط : 24414
السُمعة : 16

https://www.facebook.com/O.GodFather

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة

- مواضيع مماثلة

 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى