Posts

Showing posts from July, 2013

AppBarLayout not working with RecyclerView in android 23.0.1 -

i facing issue while implementing appbarlayout animation recyclerview. not working. if replace recyclerview nesterrecyclerview works fine. please me fix this... <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true"> <android.support.design.widget.appbarlayout android:id="@+id/main.appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/main.collapsing" android:layout_width="match_parent" android:layout_height="wrap_content" app:la...

asp.net - Remove connection from all groups in SignalR -

how can remove specific connection groups in signalr? - in application connection of specific user can associated several groups. don't want use database track association of connection groups. signalir docs the simplest solution iterate on groups , remove connection id each of them. there isn't inbuilt method in signalr this.

How to implement SearchView with Toolbar in Android? -

Image
i trying implement toolbar have done in android studio, cannot figure out how add searchview once search icon clicked. this want toolbar when search icon clicked. this toolbar.xml file: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="#000000" android:elevation="5dp" android:contentinsetleft="15dp" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bean" android:layout_gravity="center" android:textcolor="@color/beanblue" android:id="@+id/toolbar_title" ...

google apps marketplace - Gmail Gadget Error 406 being thrown on osapi.http.post -

we have multiple marketplace apps use gmail contextual gadgets. these have been running years successfully. we noticing following intermittent error being thrown when calling out external web server using open social osapi.http.post "{"id":"http.post","error":{"message":"response not valid json","code":406}}" we have checked , there nothing wrong our server. can make call directly our server without fail. we can replicate issue calling multiple servers running different apps/gadgets. commonality appears use of osapi.http.post. here post osapi.http.post({ 'body': postdata, 'href': serverurl + 'ilinkstreamer.ashx?data=' + "" + settimestamp() + debugstring, 'format': 'json', 'authz': 'signed', 'nocache': true }).execute(displaystreamlist...

Error compile apk in appcelerator -

i try compile apk using appcelerator error , using module ti.cloudpush. how solve it. currently i'm using titanium sdk: 5.2.0.ga [error] : failed run dexer: [error] : [error] : uncaught translation error: java.lang.illegalargumentexception: added: lcom/google/android/gms/dynamic/lifecycledelegate; [error] : uncaught translation error: java.lang.illegalargumentexception: added: lcom/google/android/gms/auth/googleauthutil; [error] : uncaught translation error: java.lang.illegalargumentexception: added: lcom/google/android/gms/auth/userrecoverableauthexception; [error] : uncaught translation error: java.lang.illegalargumentexception: added: lcom/google/android/gms/auth/googleauthexception; [error] : uncaught translation error: java.lang.illegalargumentexception: added: lcom/google/android/gms/auth/googleplayservicesavailabilityexception; [error] : uncaught translation error: java.lang.illegalargumentexception: added: lcom/google/android/gms/auth/userre...

angularjs - What if a file does not exist in local storage for angular.js ngStorage? -

(javascript) var app = angular.module('app', ['ngstorage']); app.config(function($scope, $localstorageprovider){   var userlogstatus = $localstorageprovider.get('userloggedin');   if (userlogstatus === 'null') {     $scope.loggedinout = 'partials/pagelink.html';   } else {     $scope.loggedinout = 'partials/anotherpage.html';  &nbsp} }; (html) <div ng-include="'{{loggedinout}}'"></div> the code mentioned above not working. value of userlogstatus taken null in javascript because file not exist in local storage of website. please correct code mentioned above , me. you should correct line: if (userlogstatus === 'null') to this: if (userlogstatus === null)

javascript - Unsolved PHP page refreshing without Ajax [Solved - Thanks!!] -

please, can publish mistakes corrected , tested code problem? program - 22.php has form. when user enter , click submit button, result should taken 23.php , displayed in div on 22.php i tried solutions below , none of them solve problem; 1) changed to: $("#testform").submit(function(event){ 2) included "return false;" @ end prevent submit form , reload page. 3) clear browser cache i can see happen program computer; 1) not error message after click submit. 2) can see tab of page reloads , entered text fields cleared. 3) no error message or result shows. <html> <head> <title>my first php page</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("#btn").click(function(event){ event.pre...

windows - Calling 2 variables -

my question in regards previous question . i got solution previous question when pass value in variable not working. start-process not able trigger batch file. assume doesn't recognize variable "$gros" . $version = read-host - prompt 'enter version copy' $gros="d:\homeware\gros\$version" start-process $gros\install.bat -wait -workingdirectory "$gros" error: start-process : parameter cannot found matches parameter name 'workingdirectory "$gros"'. @ d:\homeware\scripts\oms_deploy.ps1:66 char:64 + start-process $gros\install.bat -wait -workingdirectory "$gros" <<<< + categoryinfo : invalidargument: (:) [start-process], parameterbindingexception + fullyqualifiederrorid : namedparameternotfound,microsoft.powershell.commands.startprocesscommand try start-process $gros\install.bat -workingdirectory $gros -wait

maven - Sonatype Nexus problems downloading jars -

i trying configure sonatype nexus oss application when builds downloads jars respective repositories on web. structure of settings file is: <settings> <mirrors> <mirror> <!--this sends else /public --> <id>nexus</id> <mirrorof>*</mirrorof> <url>http://localhost:8081/nexus/content/groups/public</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <!--enable snapshots built in central repo direct --> <!--all requests nexus via mirror --> <repositories> <repository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginrep...

Optimize Elasticsearch index -

due low disk space , large amount of deleted documents inside 1 of index, need optimize command (elasticsearch 1.7) right now, index has following stats: shards: 15 * 1 | docs: 23,165,760 | size: 1.25tb will optimize api block indexing/query operation untill optimization done? will optimize api affects operations on other indexes? is possible have approximate time know how long take? sorry bad english :) and let me know if need further stats will optimize api block indexing/query operation untill optimization done? no, can run in parallel, indexing process affect optimization. new segments created, subject optimization well... will optimize api affects operations on other indexes? not directly, indirectly using additional cpu, memory , disk. is possible have approximate time know how long take? nop :-), maybe testing upfront , extrapolating number of documents/segments. be careful optimization require additional disk space. if optimize...

ios - UIActivityIndicatorView Inside TableView Cell -

i'm trying add spinner button have positioned in tableviewcell. problem spinner showing outside tableviewcell. this how implemeneted code inside cellforrowatindexpath myspinner = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylegray]; [myspinner setcenter:cell.like.center]; [cell.like addsubview:myspinner]; and when click using sender.tag [myspinner startanimating]; problem spinner working not wanted. it's showing outside cell. update with matt 's answer did work. changed code below. inside selector action. -(void) likeclicked:(uibutton*)sender uiactivityindicatorview *myspinner = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylegray]; [myspinner setcenter: cgpointmake(cgrectgetmidx(sender.bounds), cgrectgetmidy(sender.bounds))]; [sender addsubview:myspinner]; [myspinner startanimating]; code of form: [myspi...

windows - Babun or Cygwin with Meteor -

opening normal cmd prompt on windows , typing: meteor will work correctly. won't work in cygwin (or babun): zsh: command not found: meteor how make work ? adding alias works charm: alias meteor="meteor.bat"

asp.net mvc - Modify HttpContent (actionExecutedContext.Response.Content) in OnActionExecuted method of WebApi's ActionFilterAttribute -

my webapi action method returns iqueryable , want modify (apply paging & filtering) through actionfilterattribute in asp.net webapi(not mvc). following thread got how access passed model : .net web api iactionfilter.onactionexecuted return type but how can change/replace whole model else? i found it! first should cast actionexecutedcontext.actioncontext.response.content objectcontent (you should have refrence system.net.http.formatting.dll file in project) after can following : public override void onactionexecuted(system.web.http.filters.httpactionexecutedcontext actionexecutedcontext) { ienumerable model = null; actionexecutedcontext.response.trygetcontentvalue(out model); if (model != null) { iqueryable modelquery = model.asqueryable(); //do modelquery modification/replacement (actionexecutedcontext.actioncontext.response.content objectcontent).value = modelquery; } base.onactionexecuted(actionexecutedc...

pyspark - Why does my Datastax Spark app use unusual amounts of memory? -

Image
my systems memory 32gb. have 3 machines , 1 machine has 4gb 10gb , 14gb decreasing. system has run 44 hours , memory usage high , keeps increasing, lead crash. this spark executor picture: this pyspark code uses more , more memory longer runs, don't want because system crash. suggestions on how change this?: begin = datetime.now(tz) print 'begin:%s' % (begin) article_channels = articlestat.join(channels).map(lambda x:(x[1][0]['id'],{'id':x[1][0]['id'],'thumbnail':x[1][0]['thumbnail'],'title':x[1][0]['title'],'url':x[1][0]['url'],'created_at':x[1][0]['created_at'],'source':x[1][0]['source'],'category':x[1][0]['category'],'author':x[1][1]['name']})) speed_rdd = axes.map(lambda x:(x.article,[[x.at,x.comments,x.likes,x.reads,x.shares]])) \ .reducebykey(lambda x,y:x+y) \ .filter(lambda x:len(x[1])>=2) \ ...

python 3.x - Pandas XLSXwriter: open XLSX file and save with format -

problem description excelwriter pandas capable of storing xlsx files defined formats, possible capture formats , keep them datafile well? so; open xlsx file , capture number/time/date/.. formats; then save file same formats, example number, dates , time formats. examples of storing number formats can found here , , storing date , time formats can found here . mwe 1 - open xlsx file , capture formats import pandas pd datetime import datetime # capture number/time/date/.. formats here? df = pandas.read_excel("sourcefile.xlsx") 2 - save xlsx file same formats writer = pd.excelwriter("targetfile.xlsx", engine='xlsxwriter') df.to_excel(writer, sheet_name='sheet1') # set captured formats here writer.save()

php - Array params in Volley StringRequest -

i have trouble sending stringrequest. 1 of params must array here request: public void sendtowebservice(final string login, final string mdp, final reprise rep){ string url = myapplication.geturlws(); final requestqueue request = requestqueuesingleton.getinstance().getrequestqueue(); stringrequest sr = new stringrequest(request.method.post, url, new response.listener<string>() { @override public void onresponse(string response) { rep.setstatus(1); reprisedao db = new reprisedao(context); db.addvehicule(rep); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { } }){ @override protected map<string,string> getparams(){ map<string, string> params = new hashmap<string, string>(); params.put("login", login); params.put("password", mdp); ...

jquery - Drupal 7 behaviors don't work -

i'm having problem drupal behaviors seem work logged in users, not else, except when behavior executing submit() . for example won't work. drupal.behaviors.login_activate = { attach: function (context, settings) { $("#sr_login", context).hover( function(){ $(this).append($("<span> ***</span>")); }, function(){ $(this).find("span:last").remove(); } ); } }; this work. drupal.behaviors.foundation_donation = { attach: function (context, settings) { $('#monthly_submit').click(function(){ $('#monthly_donation').submit(); }); $('#single_submit').click(function(){ $('#single_donation').submit(); }); } };

c# - Visual Studio Immediate window "Internal error in the expression evaluator" -

disclaimer: checked this question immediate window. i'm using entity framework fetch results, have list of logging: var result = ctx.logging.where(*filtering*).tolist(); but want know distinct datatypes of list (an enumeration, underlying type byte , datatype nullable, if make not nullable works reason ). when try in immediate window: result.select(r => r.datatype).distinct().tolist(); i message: internal error in expression evaluator. however works fine when in code, example var test = result.select(r => r.datatype).distinct().tolist(); . tried using 'managed compatibility mode' , 'legacy expressions' debugging options message: expression cannot contain lambda expressions am missing or bug in visual studio 2015? minimal, complete, , verifiable example: class program { static void main(string[] args) { list<test> tests = new list<test>(); for(int = 0; i<100; i++) { ...

Opengl glGenVertexArrays error -

i trying make 5 vertex array objects(vao) using 1 array init() function. however, glgenvertexarrays( 5, &vao ) throws me error , don't understand why does. i guess don't understand behavior of function. can tell me what's going on here? here original code: void init(){ // subdivide tetrahedron sphere index = 0; tetrahedron( 1, 0, numtimestosubdivide-4 ); index = 0; tetrahedron( 0, 1, numtimestosubdivide-3 ); index = 0; tetrahedron( 0, 2, numtimestosubdivide-2 ); index = 0; tetrahedron( 0, 3, numtimestosubdivide-1); index = 0; tetrahedron( 0, 4, numtimestosubdivide ); // create vertex array object **glgenvertexarrays( 5, &vao ); // error occurs on line** ( int i=0; i<5; i++ ) { glbindvertexarray( vao[i] ); gluint buffer; glgenbuffers( 1, &buffer ); glbindbuffer( gl_array_buffer, buffer ); glbufferdata( gl_array_buffer, sizeof(points[i]) + sizeof(normals[i]),null, gl_static_draw ); glbuffersubdata( gl...

php - Laravel 5.2 Dingo/api resources group -

as title mentions, trying figure out how make resource group dingo. as explains laravel, correct way make resource group in route is: route::resource('item', 'api\itemcontroller'); is similar dingo/api? can say: $api = app('dingo\api\routing\router'); $api->version('v1', function($api){ $api->resources('item','app\http\controllers\api\itemcontroller'); }); when executing way, type error: argument 1 passed dingo\api\routing\router::resources() must of type array, string given does mean have make array of calls need , pass resources method? you have typo there. actual method resource not resources $api->version('v1', function($api){ $api->resource('item','app\http\controllers\api\itemcontroller'); });

php - Undefined method calling Google Drive Client -

based on example provided in google's page , installed google client sdk via composer. , trying use following codes upload file google drive: <?php header('content-type: text/plain'); require_once('vendor/autoload.php'); /** * insert new file. * * @param google_service_drive $service drive api service instance. * @param string $title title of file insert, including extension. * @param string $description description of file insert. * @param string $parentid parent folder's id. * @param string $mimetype mime type of file insert. * @param string $filename filename of file insert. * @return google_service_drive_drivefile file inserted. null * returned if api error occurred. */ function insertfile($service, $title, $description, $parentid, $mimetype, $filename) { $file = new google_service_drive_drivefile(); $file->settitle($title); $file->setdescription($description); $file->setmimetype($mimetype); // set parent folder. ...

html - How to change two Div Content in carousel -

Image
i want help, change 2 div content in same carousel. below image, have marked content in red, want change when click right or left carousel buttons. https://jsfiddle.net/austinpeter/cg7hqk0n/ <div class="col-md-12 ourworkinfo" style="position:relative;text-align:center;height:calc(100% - 142px);overflow: hidden; display:none"> <div class="col-md-12" style="padding:0"> <div style="background:#66dbff;height:50px;position:relative;padding:0;"> <div class="col-md-4"> <div id="ourworkcarousel" class="carousel slidec" data-interval="false" data-ride="carousel" style="width: 50%;padding-left: 50px;padding-right: 50px;height:50px"> <div class="carousel-inner" role="listbox" style="height:50px"> <div class="item active" style="top:10px"> ...

java - Cache filter on collection with Guava -

i'm developing program performs operations on automatas. automata made of states (aka node) , transitions (aka edges) , need filter them retrieve set particular properties. operation easy implement, performed several times , write little cache on it. in fragment of code below there implementation , i'd know if correct way filter , memoize observable transitions . public class automata { private state initial; private set <state> states; private set <transition> transitions; private supplier <set <transition>> observables; // ... public automata() { this.initial = new state(); this.states = new hashset <> (); this.transitions = new hashset <> (); this.observables = suppliers.memoize(() -> transitions.stream().filter((t) -> (t.isobservable() == true)).collect(collectors.toset())); } public getobservables() { return observables.g...

jquery - Hide table on no matches (wenzhixin's extended bootstrap table) -

i have page 3 tables. put "button formatter" on first table, when clicked sets data-url second two. example: window.actionevents = { 'click .edit': function (e, value, row, index) { $('#tabletwo').bootstraptable('refresh', { url: '/api/controllerexample/' + row.id + '/exampleactionone' }); $('#tablethree').bootstraptable('refresh', { url: '/api/controllerexample/' + row.id + '/exampleactiontwo' }); } }; now, not row "id" rows have data. , such kind of eye-sore 2 tables displaying have nothing display. the question: is possible set actionlistener table such "done loading data", , check if table empty, if perform logic (such setting div hidden) solved own question. bootstrap table supports events, listen on "load-success" event, when fires data table , check...

analytics - Presence Insights SDK not working correctly -

i working on presence insights sdk , have issue analytics. take phone , go zone have configured in presence insights website. zone says there 1 visitor. after that, go outside little bit , return previous zone. zone says there 1 visitor. doesn't increase. but when go other zone , return previous zone, previous zone says there 2 visitors. don't know if sdk still beta version. doesn't seem work correctly. when zone increase visitor if phone enters zone? it looks exit condition not met. exit events triggered when: the device detected beacon or sensor, @ different zone. the device not detected period greater device timeout . for case device travels zone zone, exit event fired after detecting device in new zone. for case device moves outside, exit event fired after device not detected beacon/sensor time period greater device timeout . device timeout can configured @ settings -> general -> application settings . default value 900000 ms (15 mins)...

php - Where shall i put woocommerce rest api library files -

i have no idea how work woocommerce library files, paste files , paste code. i have found following code : <?php require_once( 'lib/woocommerce-api.php' ); $options = array( 'debug' => true, 'return_as_array' => false, 'validate_url' => false, 'timeout' => 30, 'ssl_verify' => false, ); try { $client = new wc_api_client( 'http://your-store-url.com', 'ck_enter_your_consumer_key', 'cs_enter_your_consumer_secret', $options ); } catch ( wc_api_client_exception $e ) { echo $e->getmessage() . php_eol; echo $e->getcode() . php_eol; if ( $e instanceof wc_api_client_http_exception ) { print_r( $e->get_request() ); print_r( $e->get_response() ); } } but still have no idea, put code, uploads/add other library files. i using rest api library kloon. this may check post put library fil...

html - How do I match variables in PHP? -

for class, need create fake online dating site matches people based on variables. singles.txt file contains user's name, gender(m of f), age, personality type, favorite os, seeking genders (m,f or mf) , min/max seeking age, separated commas. code below checkboxes index.php/signup page. <input type="checkbox" name="seekmale" value="m"/>male <input type="checkbox" name="seekfemale" value="f"/>female the code below matches.php. can't figure out of seeking gender part work. if new user male seeking females, females seeking males should displayed, etc. appreciated. <?php $name = $_get["name"];//get name parameter $people = file("singles.txt", file_ignore_new_lines);//load data singles.txt ?> <h1>matches <?= $name ?></h1> <?php foreach($people $person) { list($person_name, $gender, $age, $type, $os, $min...

python - Get Laplacian pyramid using opencv -

i'm trying layer of laplacian pyramid using opencv functions: pyrup , pyrdown . in documentation , in more detail in book , found i-th laplacian layer should obtained following expression: li = gi - pyrdown(gi+1) where gi i-th layer of gaussian pyramid. what i've tried is: def get_laplacian_pyramid_layer(img, n): gi = img in range(n): gi_prev = gi gi = cv2.pyrdown(gi_prev) pyrup = cv2.pyrup(gi) return cv2.addweighted(gi_prev, 1.5, pyrup, -0.5, 0) but different sizes of images involved in substraction. don't understand because pyrup suppposed invert process of gaussian pyramid, i.e. pyrdown (with lose of information of course should not affect size, right?). update i refactored code to: def get_laplacian_pyramid_layer(img, n): '''returns n-th layer of laplacian pyramid''' currimg, = img, 0 while < n: # , currimg.size > max_level (83) down, = new_empty_img(img.shape), ne...

django - Bootstrap navbar collapse menu does not work over https -

i using bootstrap 3.3.2 django 1.8.8 build website. using mod-wsgi version 4.4.23 , apache 2.2.15 deploy on centos vm. i have navbar fixed top, collapsible signup menu. when connect website on http , click on menu, dropdown menu items listed. when connect on https , same, dropdown menu items not displayed. same thing happens when click on minimized navbar menu items when viewport shrinks. what going wrong? the base template code here: <!doctype html> <html lang="en"> {% load staticfiles %} <head> <link href='http://fonts.googleapis.com/css?family=open+sans' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=roboto' rel='stylesheet' type='text/css'> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1...

angularjs - $timeout.cancel not working -

i trying cancel $timeout in code snippet shown below, doesn't seems working. var trial=1; $scope.trialtimeout = $timeout(countdowntime,0); function countdowntime(){ $timeout(function(){ trial++; console.log("countdowntime"); if(trial>2) { callme(); } countdowntime(); },1000) } function callme(){ console.log("this "+$timeout.cancel($scope.trialtimeout)); //$timeout.cancel(trialtimeout); } when log $timout.cancel($scope.trialtimeout) returns false means not cancelling the timeout. $scope.trialtimeout gives promise object still, unable cancel timeout.

javascript - Google maps bounds not working -

i trying set bounds of custom google map user cannot zoom out far (to point world map starts tile horizontally), , cannot drag far vertically avoid this issue. i've added code set bounds, no longer seem able drag @ (uncomment bounds code recreate). want bounds world map avoid issue in screenshot above. obvious i've missed? <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>document</title> <style> #map_canvas { width: 100%; height: 650px; } // #map </style> </head> <body> <div id="map_canvas"></div> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function coordmaptype(tilesize) { this.tilesize = tilesize; } coordmaptype.prototype.gettile = function(coord, zoom, ownerdocument) { var...

Beginning iOS 6 Development - self.statusLabel.text build failure -

it never sign when beginners book has errors related source in third chapter, here beginning ios 6 development apress. working on simple project gives 2 buttons , changes label based on name of button being pressed. the initial request book use statuslabel.text = plaintext; , failed. this discussed on thread , modified self.statuslabel.text = plaintext; , didn't resolve issue. here code: #import "bidviewcontroller.h" @implementation bidviewcontroller - (ibaction)buttonpressed:(uibutton *)sender { nsstring *title = [sender titleforstate:uicontrolstatenormal]; nsstring *plaintext = [nsstring stringwithformat:@" %@button pressed.", title]; self.statuslabel.text = plaintext; } @end the error being thrown following: property 'text' not found on object 'uiview *' i'm guessing stupid, appreciate can give me. the error spelled out pretty nicely, property 'text' not found on object 'uiview *...

Why this C code (for-loop) is looping forever? -

learning c right , i've made simple for-loop . program check if argument given has 'a' alphabet in it. int main(int argc, char *argv[]) { if(argc != 2) { printf("error: need 1 argument\n"); return 1; } int = 0; char letter; for(i = 0, letter = argv[1][i]; letter != '\0'; i++) { switch(letter) { case 'a': printf("%d: 'a'\n", i); break; default: printf("%d: '%c' not 'a'\n", i, letter); } } return 0; } the result of forever looping program, if change line: for(i = 0, letter = argv[1][i]; letter != '\0'; i++) for(i = 0, letter = argv[1][i]; argv[1][i] != '\0'; i++) , the code runs fine. why this? if ever have trouble debugging loop, helps think of for (initialise; test; increment) equivalent to: initialise; while (te...

c++ - Why does for-loop behave differently when counting up vs counting down? -

this homework question revisited. requires me not use cmath , writes function evaluate cos pi/3 . code is #include <iostream> using namespace std; double power(double x, int b) { if (b>1) return x*power(x,b-1); else if (b==0) return 1; else return x; } double cosine(double x, int k) { double tmp=0; (int n=0; n<=k; n++) { tmp += power(-1,n) / factorial(2*n) * power(x,2*n); } return tmp; } int main() { double x=3.1415/3; int k=100; cout << cosine(x,k) << endl; } i have written 2 versions of double factorial(int a) for-loops. one counts , outputs 0.500027 : double factorial(int a) { double tmp=1; (int i=1; i<=a; i++) { tmp*=i; } return tmp; } the other 1 counts down , outputs inf (but evaluate 4!=24): double factorial(int a) { double tmp=a; (int i=a; i>=1; i--) { tmp*=i; } return tmp; } why count down loop fail give convergent output? ...