Solar cheaper than Nuclear?

PhysicsIt was brought to my attention that an article published by wired this week, discussed the fact that solar power has now become cheaper per MWh than Nuclear. This must be a significant milestone to have been reached in the development of new novel power solutions to our current massive drain. We have had numerous seminars in the department over the last few years discussing new ways to make more efficient solar cells, and decreasing the reliance on expensive rare earth metals to make them.

I don’t know what the current development has been to drop the pricing below that of Nuclear, however I want to put forward that this could be somewhat of a misnomer. Nuclear has a huge (in the order of billions of £s) initial outlay, with, what wired has called huge chances of defaulting on loans (greater than 50%) which will obviously increase the interest on any loan of capital that these consortiums are taking. One of the primary reasons that nuclear is so expensive is that there has been a reduction in the number of plants being built. This must have led to a loss of the specialist knowledge required to build and manufacture the components. I put forward a discussion that had we carried on building Nuclear to keep up with the current demands then Nuclear would be significantly cheaper, enabling much cheaper power plants to be created.

If you haven’t realised by now I am a huge proponent for nuclear power, I still believe that it is the only way to keep up with the current world energy demands (well until fusion becomes a significant possibility, cheap enough to be created for domestic use). Anyone who is against Nuclear just because of the inherent risks, then you really should look up how these systems are controlled, and why catastrophes such as Chenobyl happened. Most people blindly follow their media of choice, and so until the media gets behind the only possible option to keep up with the current power draw then Nuclear is bound to fail.

Which leads back to why Solar is not the best option. Primarily it is because these require very rare earth resources, and secondly because the conversion ratio of each *cheaper* panel is well under the 50% mark.

No matter how cheap solar becomes, it will never become a more viable option than Nuclear, the only way to completely move towards solar and wind would be for each country to decrease their reliance of electricity, and decrease the amount they use.

Papers and the quest for publication

PhysicsSo it’s taken three years to get there, a lot of stress heartbreak over wrong simulations, and excitement once the results came through. But we are about to get our first (of many hopefully) published.

The paper is due to be published in Physical Chemistry, Chemical Physics (PCCP) a high impact journal by The Royal Society of Chemistry. The paper is entitled “” and considers the catalytic properties of defected Ice Ih on the dissociation of Chloro-flourocompounds (CFCs) which play a fundamental role in ozone depletion. Once the paper is published I will add link and citation here.

The journey was long, however the part that I expected to take the longest time, and from discussion with other people should have been the longest time, was actually the shortest. We received one of the best peers reviews possible with the paper being submitted finally in the original form, no edits were needed to be made.

Overall I am looking forward to having a couple of glasses of wine with friends to celebrate this achievement, which just goes to show that the work we have been doing in the group is being recognised by the scientific community as a whole!

First pass the post – time to modernise UK politics?

PhysicsWell here we go, again not strictly in the remit of the blog, but nonetheless an important issue both to science policy and to society as a whole. The question I pose to you, good readers, is ‘is it time to change from first past the post, and move to proportional representation?’.

First Past the PostHaving never really been that interested in UK politics before this general election, the Twitter trend #scivote has made me realise that politics does have a role to play in a scientists everyday life, and in my own constituency I made sure that I voted to make my #scivote count. However from watching and reading the results today it seems to me that there is a gross injustice in how the votes matter. Only weak constituencies are important in the grand scheme of things, voting against the holder of a stronghold usually is but a drop in the ocean of what is required. Swinging a constituency from one party to another requires such a large volume of votes that it is unlikely to happen, however in a area where every vote counts it can be down to 100s, or less, votes which can cause the swing from one party to another handing them another seat in the houses of parliament, and (as the BBC represented it) another slab in the road to number 10.

It is obvious that most of the rest of the world does nt understand how our politics works, with the Governor of Callifornia (Arnold Swarzenegger) calling David Cameron to congratulate him on his victory from the information from the exit polls, when not understanding that even the exit polls were showing that the Tories had not even made the majority required to stop a hung parliament. However I looked at this on the BBC website this morning, and seen that the Liberal Democrats with only 50 seats had approaching the same number of overall votes (I’m a physicist so 10M is close to 8M!) as labour and yet were 150 seats less! How is this both democratic, and bringing the peoples candidate to the job? it is this system which, in my opinion, leads to voter apathy, where people (sometimes rightly) feel that their vote is worthless, and so why bother voting.

Proportional representation however would ditch the ancient first past the post system, bringing in a government where the PM is elected by
the people, not just the people of the swing constituencies but by the people of the country. As my good friend pointed out, how then would the MPs be chosen for each constituency, to make up the total representation in the Houses Of Commons? Well to this I have no real answer, however I do feel that the voters have shown this year that now is a time for change, perhaps time to change the way government works in totality (removal of the unelected Houses of Lords as a start).

Scientific software and the perils of variables

PhysicsScientific software, known as very unforgiving software, has yet again got the better of me. It all boils down to the fact that scientific software in general requires such a huge number of variables to perform even simple calculations that you have to know exactly how each variable is going to affect the final result. For example today I have been trying to use the code ‘Octopus’ (a Time Dependent Density Functional Theory code) to repeat some calculations done using the more familiar code Quantum ESPRESSO (a Time Independent Density Functional Theory code). However as parameters are different, and systems are set up in different ways, it seems to be next to impossible to repeat this calculation.

I can totally understand the reason to have so many different variables, the more variables a code has the more effectively powerful the code is, as you are able to change parameters to fit the situation. But maybe its time to try and use the same parameter name, and using the same approximations, working in the same way. In different worlds of computer programming it has become common for something that is repeated many times for different codes to become an ‘engine’, which then people can build upon adding their own interface layers, and allowing the code to evolve into different packages, but all based upon that same principle. Would it be possible to bring a ‘DFT’ engine into development, that could then be used by different codes to try to unify the menagerie of different codes into one place.

Science for slightly inebriated Adults

SM Lates Logo

PhysicsLast night I had the privilege of being at the London Science Museum “lates” evening for March, which if you don’t know, is where the Science Museum is transformed into a play ground for adults for the evening. There is live music, from both DJ’s on different levels of the museum, and small bands in other corners, displays of interesting science (create your own cloud seemed to draw big crowds), and the chance to experiment play in the Launch Pad area with no kids in sight! Not to mention the multiple bars throughout the building for the adults to indulge in some light drinking!

The Science Museum helpers put on fantastic shows (I’m guessing that the shows are exactly the same as they are normally for the younger members of the audience – however I’ll report back Monday night on that!). We managed to see the whole of the seminar show on bubbles and how they are created. The audience participation was fantastic, and it was genuinely lovely to see so many adults being interested and enthralled by such everyday science.

Watching the adults trying to work out the experiments in the Launch Pad was fantastic, people trying to build an archway out of foam blocks without making them collapse, and the fantastic installation ‘Social Light’ by Scott Snibbe was deserving a place in the Tate Modern (more so than some of the installations which I saw there the other day). Using some kind of feedback system to detect the shadows created by a person in front of the projector to then work out on the fly the reflection that would occur on a plane to that person with a very thick beam of multicoloured light, so that the different colours (which effectively had different wavelengths) would scatter from the projected shadow – and then recording the shadow movements and image that was projected onto a website, and the artists collection (I presume that Scott will be using these again at some point in a different work of art). Reminiscent of the ubiquitous Apple iPod advert, the fun given to and images created by the adults big kids was fantastic.

Social Light

The image produced by Social Light at the Science Museum

Overall this was one of the best nights that can be had in London for free, if you are even remotely interested in science, and having a good time, then make sure you head there for the next Late’s at the Science Museum.

In other news, we are very close to publishing our first manuscript to an international journal, I have to do a final proof read of the article before we submit, and the second one is very close to fruition too.

Games and Physics, the buzzword in development?

Is this really possible with physics?

PhysicsGamesWell having played about 10 hours of the excellent Just Cause 2, and not being upset by the seemingly simple and over exaggerated physics, it is time to explore why this is. Games in general have become more and more physics orientated, what started as a real advantage for the sublime Half-Life 2 on the PC, has now become a real buzzword in the development of any game. Physics has become one of the most touted parts of a new shooter, RPG, RTS etc. Through the development of such hardware solutions as PhysX (changed from a dedicated hardware solution to becoming an integral part of the Nvidia drivers package, and the ability to run concurrently on Nvidia graphics cards), and Havok, these API’s have allowed developers to include more and more complex physics in their games. Just how important are accurate physics, and what problems come from having more and more accurate physics?

Well to start off with looking at Just Cause 2, it is simple to see that they have used a very powerful physics engine, with the ability to model non static objects as free particles – looking at some of the mods which have already been created for the PC versions, we see cascades of vehicles coming down hills which have been tethered together using the grappling hook. However the physics in the game have been simplified to increase the fun found throughout the game, for example being able to use a grapple hook to pull yourself along in a parachute and gain a height advantage over your enemies, swooping in like some kind of batman character, never grows old! The stunts and the ability for a vehicle to keep driving after performing multiple barrel rolls over a road, again adds to the ‘fun’ aspect. Not needing hundreds and hundreds of metres to be able to take off in a plane adds to both the simplisitic ‘pick up and play’ nature of the game allowing players to take off in small spaces, and the ability to land a helicopter where ever you please gives a huge amount more freedom.

Physics in general can make a game more accurate to real life, and yet with some small tweaks to engine parameters can exaggerate stunts adding an additional dimension of fun. Who wants to play a game with exact physics – where death of your character is almost guaranteed in most gaming scenarios? In fact if we are going for the exact terminology then does anyone know exact physics? As I have stated before in this blog, physics is nothing more than refined levels of accuracy in models of what physicists believe is happening, where even small changes on a sub-quantum level could change macroscopic (large observable) properties.

So where will games physics lead in the future? I personally think that games are reaching the pinnacle of what can be done with the fine graining, and particulate decomposition of current engines. Destroyed building always seem to collapse in the same way, with the same large chunks falling off, and the creation of some kind of dynamic destruction engine to decompose large static objects into smaller shards, with an aspect of randomisation so that all destructions are different would be one logical step – however as some of my colleagues have been researching even modelling simple cracks require extensive computational power, and quantum aspects to be taken into consideration. An increase in the amount of RAM memory accessible to next-gen consoles would hopefully allow engines to keep physics particles in the players view without them disappearing. The fine graining of physics will ultimately be the downfall into how accurate physics can become in games, however on the flip side it is important to remember that perfectly accurate physics would, in most probability, spoil any kind of fun there is to be had such a game.

CERN Celebration Champagne

On a side note I’d like to congratulate the guys and girls at CERN for colliding two proton beams in the LHC at 7 TeV, quite an achievement, lets hope we get to see the new physics soon! (Oh, and the world wasn’t destroyed by black holes……).

My Research

PhysicsMy current area of research is in the application of Quantum Mechanics to model atmospheric systems, namely looking at the interface between multiple water molecules (H_2O)_n forming nano clusters and the attachment of an excess electron forming an anionic species (H_2O)^{-}_n. These models are important in multiple disciplines, as in biology anionic water clusters could be responsible for radiation damage, pollutants modelled in anionic water clusters are important for atmospheric science as the additional charge could potentially act as a catalyst in the atomic dissociation of the Halides in the pollutants forming free radicals.

CR-Molina Cycle

The CR reaction pathway for the Molina Cycle

I am studying different sized water cluster models and how accurate they are as an approximation for atmospheric sciences, initialing looking at the sizes required to bind an excess electron to the geometry, defined as a negative Vertical Detachment Energy (VDE), the energy gained from the addition of an extra electron into the anionic geometrical structure, denoted by the index ’1′.

E_{VDE} = E^{*}_{1} - E_1

Particular attention has been taken to the dimer (H_2O)_2 in both the neutral and anionic forms, and the water trimer (H_2O)_3, where quantum dynamics have been performed on the trimer using the Car-Parrinello Molecular Dynamics to allow the system to evolve in time, where the electronic wave-functions effectively follow the ionic movements and stay close to the Born-Oppenheimer surface. We have seen that in the anionic water trimer the favoured geometrical structure is a linear shape, with the loss of a hydrogen bond, which has lead to the discussion that the geometry is defined through the maximisation of the dipole moment of the structure, allowing the electron to become dipole bound.

Linear Trimer

Linear water trimer, with the contour showing 90% of the excess electron density.

Further work has been undertaken into the water dimer, looking at the system using time-dependent Density Functional Theory (TD-DFT) allowing us to observe the evolution of the electronic wave-functions in time, and study the response function in a linear regime. Through this the far infra-red (FIR) spectra of the system can be constructed and observed. As a significant aside to this TD-DFT project a biologically important molecule H_2O-NO is being studied, NO is well known as a neuro-receptor, and plays important roles in the body.

Continual increase in the number of water molecules studied has led to the creation of deformed ice surfaces which allow the spatial localisation of an excess electron. This has been considered a good candidate model for Cosmic Ray induced dissociation of CFC’s which is a different reaction pathway for the Molina cycle. Excess electron induced catalysis has been seen to occur on the simplest CFC (CCl_4) in an almost instantaneous time frame (sub pico-seconds), where the formation of the Cl free radical is more energetically stable than the whole CFC on the surface. It was observed that the radical is triply hydrogen bonded to the surface, with the additional electron spatially localised on the halogen.

Dissociated CFC with halogen free radical bound through hydrogen bonds to the ice surface.

Further research will be completed into the modelling of pollutants with larger water clusters, using the long range Coulomb Screen implemented into the Plane Waves Density Functional Theory (DFT) code Quantum ESPRESSO. Where of particular importance will be the observation of the dynamical behaviour of the structures at finite temperatures using the CPMD engine.

*That* TV Interview

GamesPhysicsWell I promised myself (and consequently my blogger housemate – GJOB) that I would keep this blog professional, and so not be commenting on current affairs, or even games – I know theres a games category but that was for another reason. But after watching the debacle that was the Alan Titchmarsh interview with Tim Ingham, Julie Peasgood, and Kelvin MacKenzie talking about how games are corrupting our society, I felt it couldn’t be ignored.

For those of you who haven’t seen it here’s the youtube video – watch it then read the rest of this post.

First of all, the comment made by Peasgood about the statistics which she stated as fact were provided to the public in the wrong way, I’m sure at the time the report was released it was not sensationalised by the scientists involved. She made no reference to the people who undertook the study, the journal the study was reported in, or even how the study was conducted for example what games were considered as violent? Questions should be asked, and rightly so, as to how they gauged the level of ‘violent tendencies’ in these children. Also as an aside what parent in their right mind would agree to a study whereby they allow their children to play these violent games?

The audience in the TV studio was out for blood, the booing on the mention of the Byron report was disgusting (I won’t mention any opinion as to whether I feel the report was justified or not, because I have not read it, and so cannot make a valid opinion, and don’t want to appear hypocritical). Do the general public have no respect for governmental research anymore, and is this an indication of the state of public mind with respect to research – with all the so called ‘scandals’ recently its hard not to go someway to understanding this viewpoint. However it is also important for the general public to realise that all of the research undertaken in this country (and in all other countries by reputable scientists) should be respected – but also should not be taken as fact. One of the first things you realise when studying physics to a high level is that everything we think we know as fact is actually a mathematical model of what we believe is happening, whereby every time scientists discover something new then more often than not models have to be updated. But I digress, back to the topic at hand.

It is time for television to take account for the level of truth of the information given to the general public, we now live in ‘the Sun’ times where the majority of people’s opinions and facts come verbatim from such poor (in my opinion) news aggregates such as the Sun, and Daily Mail. The problem is that statistics provided as fact on television shows are taken onboard as fact by the viewers. Has Peasgood ever even read the article in question, or has she just read and spouted the information from another news source? Alas the simplest answer would be for people to form their own opinions about news, and come to their own conclusions, however I fear that unless we change the way children are taught in schools then this will never happen.

I’d like to congratulate Tim for keeping so cool under such a blatant attack on the games industry by people who actually have no right to be discussing the industry in such an open (and biased) forum. The one interesting fact that seemed to be totally glossed over in the discussion (obviously they didn’t have any pre-prepared answers for it) was the simple fact that only 1 in 20 games could be considered to be overly violent – that means that 19 out of every 20 games created is a non-violent game suitable for minors. Which, as Tim rightly stated, parents should be buying and playing with their children! Some of the best times in a child’s early years could be playing games with their parents. Gaming is now mainstream, the next generation of parents will be people who remember this furore over violent games, and will understand the importance of protecting their children in the right way, by understanding and playing games with their children. However, right now it is important to remember gaming is a mainstream media, with mainstream age certificates!

With these certificates and the collaboration of all the games retailers it should be no longer possible for a minor to purchase a game rated above their age. I for one would be happy to have to produce ID when buying a video game rated 18, just like I have to do to buy alcohol – Challenge 21 should extend far beyond the reaches of the bars and clubs. It is no longer right to villainise the games industry for these games reaching the hands of minors, the games retailers cannot be blamed as they have measures in place to stop the sales, so who is left? Obviously that just leaves the parents and the children themselves. We cannot expect children to suddenly realise violent games are wrong, so that just leave the parents. How many parents have bought their children GTA? Even after all the bad press that the game series has received I believe that most parents still gloss over the big 18 sticker on the outside of the game, believing that no game could rival the sense of horror or violence found in most films. It’s time to see the sticker and realise, maybe I shouldn’t be buying this game for my child!

The onus now passes to the parents or legal guardians of the child – no more should parents be using the excuse of ignorance. It is time that if parents want to start protecting them from so called ‘morally corrupt’ media then they should start by stepping up to the plate, and stopping children from seeing inappropriate material, and buying them inappropriate video games.

Simple Calculator: Adding additional functionality

CocoaFollowing on from the initial calculator design, extensions to allow the additional functionality of single float point memory. Adding this is fairly simple, when you remember that previously we were able to send the characters from the display to a float variable and then perform an operation on them.

Instead of sending the float to the number series which would then be used for the calculation a new float variable was created allowing for the number to be stored as long as the program has been executed.

To enable the user to see if the memory is active an additional display was added to the calculator GUI which would display the action of the new buttons. Again using NSMutableStrings (I have a feeling they will become my new best friends in Cocoa), we are able to append the output sent to this new display.

Recalling the memory is as simple as pulling the stored float and appendFormat of the output (SCDisplay) string to accommodate it, then passing it to the output display. Clearing the memory is a bit more complex, as when using a desktop calculator it requires that the number on the display is the same as the one stored in the memory for the ‘M-’ function to work. By just using a simple if statement we are able to check that the numbers are equivalent, then set the stored float to zero.

Finally it is important to add the ability to clear the information from the display clearing both the operating float (number1 and number2) and setting the output string back to an effective nil value (unfortunately the string itself cannot be set to nil, so instead is set to zero characters through setString:@””).

All that was then required was to fire up the compiler to check that everything worked (funnily enough first time it didn’t work at all and crashed due to an exception – using breakpoints soon solved that problem however!). Everything works as expected, and even Cocoa has the added ability to catch infinite value so dividing by zero doesn’t cause any issues (this is notorious problem with FORTRAN and has to be checked for).

// Added to the end of SCButtons.m
// To add additional functionality to the calculator
- (IBAction)buttonClear:(id)sender {
number1 = 0;
number2 = 0;
[displayMemory setString:@"CLR"];
[textMemory setStringValue:displayMemory];
[SCDisplay setString:@""];
[textOutput setStringValue:SCDisplay];

}

- (IBAction)buttonMminus:(id)sender {
[displayMemory setString:@"M-"];
[textMemory setStringValue:displayMemory];
if ( [SCDisplay floatValue] == floatMemory )
{
floatMemory = 0;
}
}

- (IBAction)buttonMplus:(id)sender {
[displayMemory setString:@"M+"];
[textMemory setStringValue:displayMemory];
floatMemory = [SCDisplay floatValue];

}

- (IBAction)buttonMrecall:(id)sender {
[displayMemory setString:@"MR"];
[textMemory setStringValue:displayMemory];
//Show current memory string in main outbox
[SCDisplay appendFormat:@"%2.3f",floatMemory];
[textOutput setStringValue:SCDisplay];
}
@end

Simple Calculator

CocoaAfter completing the simple program ‘Hello World’, it is time to start coding something useful. After a quick decision (well actually lets be honest with a new language one of the first programs to write is the obligatory calculator application). However I decided to add a small twist to the Calculator, making it effectively the same as the one you most probably have on your desk right now. Not only would the calculator do simple operations like + – * / =, but it would also have a working single float memory – with the ability to set clear and recall that memory, and a clear button for the whole display.

First of all I needed to create a new Cocoa Application project in XCode, then I got to play with the lovely Interface Builder – adding buttons and text fields to work as the input and output, and playing with the inspector properties of each section until I was happywith the desired look.

Simple Calculator

Then we need to create a new class account for the input/output buttons on the .xib file, through the File -> New File menu, and choosing the Objective-C Class template. By convention the start of the filename should be an identifier to the program (SC for Simple Calculator here), with the secondary name of Buttons, as this class will control all input/output from the GUI.

To enable the calculator to perform simple operations I used a simple integer flag system (calcOp) to determine the operator, and NSMutableStrings to allow both the main display and the memory information to be continually updated with additional button presses. As the string is Mutable it is possible to append additional characters to the string through the command on line 1, and then to convert the display string into a float value with line 3:

[SCDisplay appendString:@"3"];
...
number1 = [SCDisplay floatValue];

Where SCDisplay is a NSMutableString and number1 is a float value. The Interface Builder creates the code for the @interface SCButtons once the GUI has been created and inputs and outputs linked to the buttons.

//
//  SCButtons.h
//
//  Created by Delphi on 21/03/2010.
//  Copyright 2010. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface SCButtons : NSObject {
    IBOutlet id textOutput;
    IBOutlet id textMemory;
}
- (IBAction)button0:(id)sender;
- (IBAction)button1:(id)sender;
- (IBAction)button2:(id)sender;
- (IBAction)button3:(id)sender;
- (IBAction)button4:(id)sender;
- (IBAction)button5:(id)sender;
- (IBAction)button6:(id)sender;
- (IBAction)button7:(id)sender;
- (IBAction)button8:(id)sender;
- (IBAction)button9:(id)sender;
- (IBAction)buttonDecimal:(id)sender;
- (IBAction)buttonDivide:(id)sender;
- (IBAction)buttonEquals:(id)sender;
- (IBAction)buttonMinus:(id)sender;
- (IBAction)buttonPlus:(id)sender;
- (IBAction)buttonTimes:(id)sender;
@end

Working within the SCButtons.m file the string was appended with the integer or decimal information as pressed within the GUI, only once an operator is pressed does the string information change into a float value, and the string be set back to an empty string.

[SCDisplay setString:@""];

Only once the final operator (the equals) is pressed, does the second string get changed into a float and passed along with the operator into the simpleCalculation function. This uses a simple series of if statements to perform the correct operation and return a float.

/ / Continuation of SCButtons.h
float simpleCalculation( float n1, float n2, int op )
{
	float simpleAnswer = 0;
	if ( op == 1 ) // Divide
	{
		simpleAnswer = n1 / n2;
	}
	if ( op == 2 ) // Minus
	{
		simpleAnswer = n1 - n2;
	}
	if ( op == 3 ) // Plus
	{
		simpleAnswer = n1 + n2;
	}
	if ( op == 4 ) // Times
	{
		simpleAnswer = n1 * n2;
	}
	return simpleAnswer;
}

One of the hardest problems I came across coding this simple application was changing the float back into a string so it could be displayed on the output. In the end I had to AppendFormat on the NSMutableString which is equivalent to writing the float back to the string in character form. This is then displayed in the output window (textOutput).

//
//  SCButtons.m
//
//  Created by Delphi on 21/03/2010.
//  Copyright 2010. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SCButtons.h"

@implementation SCButtons

NSMutableString *SCDisplay = nil;
NSMutableString *displayMemory = nil;
int calcOp;
float number1, number2, answer, floatMemory;

+ (void)initialize
{
	SCDisplay = [[NSMutableString alloc] initWithString:@""];
	displayMemory = [[NSMutableString alloc] initWithString:@""];
	calcOp = 0;
}

- (IBAction)button0:(id)sender
{
	[SCDisplay appendString:@"0"];
	[textOutput setStringValue:SCDisplay];
}

// Same for buttons1-9

}

- (IBAction)buttonDecimal:(id)sender {
	[SCDisplay appendString:@"."];
	[textOutput setStringValue:SCDisplay];

}

- (IBAction)buttonDivide:(id)sender {
	number1 = [SCDisplay floatValue];
	[SCDisplay setString:@""];
	calcOp = 1; // Division Operator
	[textOutput setStringValue:SCDisplay];

}

- (IBAction)buttonMinus:(id)sender {
	number1 = [SCDisplay floatValue];
	[SCDisplay setString:@""];
	calcOp = 2; // Subtraction Operator
	[textOutput setStringValue:SCDisplay];
}

- (IBAction)buttonPlus:(id)sender {
	number1 = [SCDisplay floatValue];
	[SCDisplay setString:@""];
	calcOp = 3; // Addition Operator
	[textOutput setStringValue:SCDisplay];
}

- (IBAction)buttonTimes:(id)sender {
	number1 = [SCDisplay floatValue];
	[SCDisplay setString:@""];
	calcOp = 4; // Multiplication Operator
	[textOutput setStringValue:SCDisplay];
}

- (IBAction)buttonEquals:(id)sender {
	number2 = [SCDisplay floatValue];
	[SCDisplay setString:@""];
	answer = simpleCalculation( number1, number2, calcOp );
	[SCDisplay appendFormat:@"%2.3f",answer];
	[textOutput setStringValue:SCDisplay];

}

If you have never coded before then I am sure that this looks like a huge mess, which is very hard to follow and understand, when in actual fact this is some very simple code, just following a logical pathway to the end function.

Follow

Get every new post delivered to your Inbox.